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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---