Forum: Ruby on Rails rails app with mod_proxy

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
flori (Guest)
on 2005-11-12 12:49
(Received via mailing list)
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
sean (Guest)
on 2005-11-12 12:49
(Received via mailing list)
Dont...

have it translated on its way back out...

mod_proxy can do translation both ways.
flori (Guest)
on 2005-11-12 12:49
(Received via mailing list)
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?
sean (Guest)
on 2005-11-12 12:49
(Received via mailing list)
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.
flori (Guest)
on 2005-11-12 12:49
(Received via mailing list)
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
ezra (Guest)
on 2005-11-12 12:49
(Received via mailing list)
On Nov 10, 2005, at 5:50 AM, Florian Frank wrote:

> module ActionController
>
> 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


Florian-

	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-vhos...
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@yakima-herald.com
This topic is locked and can not be replied to.