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
If you know the hostnames for your different environments, you could set them statically, which routes around the problem:
and then
(notice that you’re not setting the port separately, you’re just counting on it being included in host)