Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6929841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:22:11+00:00 2026-05-27T11:22:11+00:00

in my setup I’ve got nginx running on port 3000 acting as a proxy

  • 0

in my setup I’ve got nginx running on port 3000 acting as a proxy to my rails app running on port 2999. Obviously, I have to have the rails app use 3000 as the port for generated URL’s (so that when I use login_url, it will generate an url like http://localhost:3000/login.

I overrid rails’ default_url_options like this:

def default_url_options( options = {} )
  options.merge( { :only_path => false, :port => 3000 } )
end

However, this causes URL’s like http://localhost:2999:3000/login for login_path.

Only thing I found was this ticket describing a related problem: https://rails.lighthouseapp.com/projects/8994/tickets/1106-rewrite_url-adds-port-twice, but there’s nothing helpful in there.

Is there any way to make rails get the URL right?

thx in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:22:12+00:00Added an answer on May 27, 2026 at 11:22 am

    If you know the hostnames for your different environments, you could set them statically, which routes around the problem:

    # config/environments/production.rb
    DEFAULT_HOST_WITH_PORT = 'http://myrealsite.com:3000'
    
    # config/environments/development.rb
    DEFAULT_HOST_WITH_PORT = 'http://localhost:3000'
    
    # config/environments/test.rb
    DEFAULT_HOST_WITH_PORT = 'http://localhost:3000'
    

    and then

    def default_url_options( options = {} )
      options.merge(:only_path => false, :host => DEFAULT_HOST_WITH_PORT)
    end
    

    (notice that you’re not setting the port separately, you’re just counting on it being included in host)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Setup : I have a Struts web application where I use displaytag elements to
SETUP : I have this app which has 4 activities in a linear path,
My setup: I have a webview in my iPhone app, going to www.mysite.com. Trials
My setup: Rails 3.0.9, Ruby 1.9.2 My app needs to serve up a mobile
Setup Have you ever had the experience of going into a piece of code
Setup I have a website that draws RSS feeds and displays them on the
Setup: I have an HTML page with a fieldset element. The background color of
Setup I have a VBScript for driving the stress testing of a web service.
Setup: I have a COM DLL that calls a method inside a managed C#
Setup: I have a UITextView inside a UITableViewCell 's contentView . I want it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.