Redirect without port number?


#1

On my host I run my lighttpd instance bound to a specific port and my
hostname is mapped to this port (I’m not exactly sure how this is
accomplished, but it is lighttpd also listening on port 80 which handles
this for me I believe).

A redirect from rails includes my local port number in the request, so
that
it shows up in the address bar. I prefer people not to see this - I
don’t
want bookmarks saved with it for example in case I move my host or port.

I have this issue both with my custom application and with Typo. In my
app I
tried url_for :only_path => true which didn’t seem to help, and I’m not
enamored with doing this in Typo and then re-doing it if I ever upgrade,
is
there a way to “hide” the port number from rails?


#2

Jeremy - who do you host with?

I imagine your config is something like this:

Apache (port 80) -> Lighttpd (some port) -> FCGI -> Rails

This is how my apps are handled. When you visit your app’s site, are
you calling it with the port name added or by host name?

Do you care to show an example URL that we can try?


#3

I’m hosted with theinternetco.net. Apache couldbe on port 80 but if you
just
go to that IP address (no host name) then you see Lighty’s start page.

An example URL is in my sig - www.jeremyhuffman.com but you have to
login to
the admin section to see the redirect issue. I can construct a simple
example of how to see the issue if you think it would help.


#4

Actually I just realized, you can see the issue if you access
http://www.jeremyhuffman.com/admin since it will redirect for a login
prompt.

I think it is lighty doing the port mapping because of what you see
when you just look at that IP:

http://204.10.124.77

On 3/21/06, Jeremy H. removed_email_address@domain.invalid wrote:

On 3/21/06, Michael G. removed_email_address@domain.invalid wrote:

don’t

Jeremy H.
http://www.jeremyhuffman.com


Jeremy H.
http://www.jeremyhuffman.com


#5

(I’m not exactly sure how this is
accomplished, but it is lighttpd also listening on port 80 which
handles
this for me I believe).
Sorry, I am having trouble interpreting this. Does this mean your
site is using port 80?

A http request contains the domain and port. The httpd (or lighttpd)
process looks for a matching domain and port in your configuration
and generate the page (if it exists) as a response. If no port is
specified it defaults to port 80, but https connection default to
443. If you are not using port 80 (or 443) then you cannot hide the
port from the user. If you are using port 80 then it sounds like your
site configuration in the httpd process has defined the port within
the domain somehow.

-John


John S.
Computing Staff - Webmaster
Kavli Institute for Theoretical Physics
University of California, Santa Barbara
removed_email_address@domain.invalid
(805) 893-6307


#6

The other odd thing about this, is that it is only an issue if I bind
my own lighty to my port for FastCGI. If I just run webrick the
issue doesn’t appear. So it becomes harder to blame a strange
configuration with whatever proxies for me. Still, if no one else is
seeing this issue then its clearly related to my configuration. And I
suppose I should just ask my admin for help - I was just hoping there
was an easy work around for it in rails.

On 3/21/06, Jeremy H. removed_email_address@domain.invalid wrote:

I have this issue both with my custom application and with Typo. In my app I
tried url_for :only_path => true which didn’t seem to help, and I’m not
enamored with doing this in Typo and then re-doing it if I ever upgrade, is
there a way to “hide” the port number from rails?


Jeremy H.
http://www.jeremyhuffman.com


Jeremy H.
http://www.jeremyhuffman.com


#7

My host has a lighty instance listening on port 80 that proxies to my
port, 5194. I can run any process I want on my port. If I run my app
with webrick everything is fine, the browser only talks to port 80 and
its proxied based on the host header - the end user has no way of
knowing about port 5194. Rails also thinks its running on port 80 and
when it redirects it redirects to host http://www.jeremyhuffman.com so
everything remains fine.

If I run my own lighty process and dispatch.fcgi then rails finds that
the host name is http://www.jeremyhuffman.com:5194 and will redirect
to this URL. I want rails to not include the reverse proxy port in its
redirects.

On 3/22/06, John S. removed_email_address@domain.invalid wrote:

http://www.jeremyhuffman.com


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Jeremy H.
http://www.jeremyhuffman.com


#8

Well, in fact it IS working and if you read my post or clicked the URL
you
would understand that. I suppose it must be apache doing the front if
Lighty
can’t do it; I really don’t know the configuration I just know
everything is
fine UNTIL Rails does a redirect. So in fact there is a ReverseProxy.


#9

Jeremy-

As far as I know lighty as a front proxy like that can't do the

reverse proxy like you want. Apache fronts like what you are
describing use ProxyPass and ProxyPassReverse to do the forward/
backward proxy. Lighty doesn’t do reverse proxies. So unless you can
get the host to switch to an apache front or someone knows a hack to
make lighty do reverse proxies I think you’re stuck with the post
number in the url.

Here is a few apache vhosts that do the right thing and let you run

lighty on a higher port without the port num showing up in the url:

http://brainspl.at/articles/2005/11/08/apache-vhost-to-proxy-thru-to-
lighttpd-on-a-higher-port

-Ezra