Hi, I want to run a rails app behind a mod_proxied apache web server. So I need to tell rails to create urls for the frontend web server instead of the hostname:port (localhost:3000 in this case) it really is listening on. I haven''t found a way to configure rails to do this. I have hacked rewrite_url for a temporary fix like this atm: module ActionController class UrlRewriter alias old_rewrite_url rewrite_url def rewrite_url(path, options) url = old_rewrite_url(path, options) url.gsub!(/a.do.main:3000/, ''b.do.main'') url end end end But I think it would be useful if rails offered this via a configuration option for similar cases. What do you think? Florian
Dont... have it translated on its way back out... mod_proxy can do translation both ways. Florian Frank wrote:> Hi, > > I want to run a rails app behind a mod_proxied apache web server. So I > need to tell rails to create urls for the frontend web server instead > of the hostname:port (localhost:3000 in this case) it really is > listening on. I haven''t found a way to configure rails to do this. > > I have hacked rewrite_url for a temporary fix like this atm: > > module ActionController > class UrlRewriter > alias old_rewrite_url rewrite_url > > def rewrite_url(path, options) > url = old_rewrite_url(path, options) > url.gsub!(/a.do.main:3000/, ''b.do.main'') > url > end > end > end > > But I think it would be useful if rails offered this via a > configuration option for similar cases. What do you think? > > Florian > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sean T Allen wrote:> mod_proxy can do translation both ways.Hmm, it translates the created links in the html/xml pages? How do I configure this?
Florian Frank wrote:> Sean T Allen wrote: > >> mod_proxy can do translation both ways. > > > Hmm, it translates the created links in the html/xml pages? How do I > configure this? > _______________________________________________No it doesnt do that... you can have rails create your links without the host information... which takes care of the in html... and mod_proxy can take care of the rest. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I put in a request for something very similar to this for the same thing... See http://dev.rubyonrails.com/ticket/2602 It was rejected by one of the devs but I reopened it with *hopefully* a better explanation. Feel free to add to this your concerns about proxying. -bph -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Florian Frank Sent: Thursday, November 10, 2005 7:50 AM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails] rails app with mod_proxy Hi, I want to run a rails app behind a mod_proxied apache web server. So I need to tell rails to create urls for the frontend web server instead of the hostname:port (localhost:3000 in this case) it really is listening on. I haven''t found a way to configure rails to do this. I have hacked rewrite_url for a temporary fix like this atm: module ActionController class UrlRewriter alias old_rewrite_url rewrite_url def rewrite_url(path, options) url = old_rewrite_url(path, options) url.gsub!(/a.do.main:3000/, ''b.do.main'') url end end end But I think it would be useful if rails offered this via a configuration option for similar cases. What do you think? Florian _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sean T Allen wrote:> No it doesnt do that... > > you can have rails create your links without the host information...You mean, I should use relative urls with absolute pathes? Yes, this would be possible for the links. The situation is a bit more complicated, though. Actually I am trying to get typo (typo.leetsoft.com) to run from this configuration, and they use url_for heavily. This could be a typo problem, but I don''t think so, because rails trys to build the absolute urls with the hostnames and fails to do it correctly in this setup. If url_for isn''t intended to build the absolute urls, it shouldn''t try to put in the hostnames in the first place. It should be either restricted to only create relative urls with absolute pathes, or do it correctly. In the case of typo it''s necessary to have absolute urls for the rss feed creation. It is also necessary to create registrations emails with click confirmation. It''s of course possbile to force application developers to take care of adding hostnames and ports in front of the absolute pathes, but shouldn''t rails make developing apps easier instead of luring developers into introducing such errors in their apps? Florian
On Nov 10, 2005, at 5:50 AM, Florian Frank wrote:> Hi, > > I want to run a rails app behind a mod_proxied apache web server. > So I need to tell rails to create urls for the frontend web server > instead of the hostname:port (localhost:3000 in this case) it > really is listening on. I haven''t found a way to configure rails to > do this. > > I have hacked rewrite_url for a temporary fix like this atm: > > module ActionController > class UrlRewriter > alias old_rewrite_url rewrite_url > > def rewrite_url(path, options) > url = old_rewrite_url(path, options) > url.gsub!(/a.do.main:3000/, ''b.do.main'') > url > end > end > end > > But I think it would be useful if rails offered this via a > configuration option for similar cases. What do you think? > > Florian > \Rails mailing listFlorian- I have a good vhost config that does what you want on my blog. Here is a link: http://brainspl.at/articles/2005/11/08/apache-vhost-to-proxy-thru-to- lighttpd-on-a-higher-port That will let you run lighttpd behind apache. Lighty can run on whatever port you want but the urls will never show the port number this way. Hope this helps- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org