Reynard | 20 Jul 09:49

how does request.host get set?


how does request.host get set? Is there a way to manually set the
value in request.host?
I have several application servers running rails, each has its own
internal address in the request.host, so when calling redirect_to or
url_for function, it uses the internal address which is not accessible
to the user.

what I want is to set request.host to return mysite.com, no matter
which application server it's running on.

- reynard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Frederick Cheung | 20 Jul 12:41

Re: how does request.host get set?


On 20 Jul 2008, at 08:49, Reynard wrote:

>
> how does request.host get set? Is there a way to manually set the
> value in request.host?

Probably based on environment variables passed through by whatever is  
sitting in front of mongrel (assuming that's the setup you're using).
In something like nginx you can tell it to pass though various headers  
eg:
proxy_set_header Host $http_host;

Fred
>
> I have several application servers running rails, each has its own
> internal address in the request.host, so when calling redirect_to or
> url_for function, it uses the internal address which is not accessible
> to the user.
>
> what I want is to set request.host to return mysite.com, no matter
> which application server it's running on.
>
> - reynard
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
(Continue reading)

Reynard | 20 Jul 16:37

Re: how does request.host get set?


Thanks for the hints. I'm using apache & mongrel. I think I found
where it gets set, in the cgi_process.rb, apparently
env["HTTP_X_FORWARDED_HOST"] is used to get the host, in my case there
are 2 values, the public and the private address, it happens to take
the latter. now I need to find where HTTP_X_FORWARDED_HOST gets set.
it seems that it should be apache conf thing right?

- reynard

On Jul 20, 6:41 am, Frederick Cheung <frederick.che...@...>
wrote:
> On 20 Jul 2008, at 08:49, Reynard wrote:
>
>
>
> > how does request.host get set? Is there a way to manually set the
> > value in request.host?
>
> Probably based on environment variables passed through by whatever is  
> sitting in front of mongrel (assuming that's the setup you're using).
> In something like nginx you can tell it to pass though various headers  
> eg:
> proxy_set_header Host $http_host;
>
> Fred
>
>
>
> > I have several application servers running rails, each has its own
(Continue reading)

Frederick Cheung | 20 Jul 17:11

Re: how does request.host get set?


On 20 Jul 2008, at 15:37, Reynard wrote:

>
> Thanks for the hints. I'm using apache & mongrel. I think I found
> where it gets set, in the cgi_process.rb, apparently
> env["HTTP_X_FORWARDED_HOST"] is used to get the host, in my case there
> are 2 values, the public and the private address, it happens to take
> the latter. now I need to find where HTTP_X_FORWARDED_HOST gets set.
> it seems that it should be apache conf thing right?
>
Yup, that should be an apache thing

Fred
> - reynard

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reynard | 20 Jul 17:57

Re: how does request.host get set?


interesting finding: you have to set ProxyPreserveHost On in Apache,
so it does not append the local server name.

- reynard

On Jul 20, 11:11 am, Frederick Cheung <frederick.che...@...>
wrote:
> On 20 Jul 2008, at 15:37, Reynard wrote:
>
>
>
> > Thanks for the hints. I'm using apache & mongrel. I think I found
> > where it gets set, in the cgi_process.rb, apparently
> > env["HTTP_X_FORWARDED_HOST"] is used to get the host, in my case there
> > are 2 values, the public and the private address, it happens to take
> > the latter. now I need to find where HTTP_X_FORWARDED_HOST gets set.
> > it seems that it should be apache conf thing right?
>
> Yup, that should be an apache thing
>
> Fred
>
> > - reynard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
(Continue reading)


Gmane