Rails on lighttpd through proxy


#1

Hi All,

We have a PHP site running on apache 1.3 and Im trying to graft typo
onto it at /blog/. Ive got the running using the symlink method but
apache/fastcgi are clunky to say the least so I want to move typo over
to lighttpd. Ive got this all working and Im now trying to get a
proxy working through from apache. Im using this:

RewriteRule ^/blog/?(.*)$ http://blog.myorg.net:8080/$1 [P]

This is working fine apart from Rails thinks its at the root of the
site so all the links (from link_to etc) come out as
/articles/whatever instead of /blog/articles/whatever. Does anyone
know of a way around this or even an alternative set up which might
work. I would even consider moving the PHP portion of the site over
if that makes it easier. Any wisdom on this? Ive ploughed through
all the wiki and other articles on the subject but found no solution
as yet.

Hope someone can help me out, Ive been tearing my hair out over this for
days…

Thanks in advance for saving what’s left of my hair,


Dan W.
http://www.danwebb.net


#2

On 11/28/05, Dan W. removed_email_address@domain.invalid wrote:

This is working fine apart from Rails thinks its at the root of the
Thanks in advance for saving what’s left of my hair,


Dan W.
http://www.danwebb.net


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

Use
ProxyPass /blog http://blog.myorg.net:8080
ProxyPassReverse /blog http://blog.myorg.net:8080

in the config of the apache playing the role of proxy.

Raph


#3

Raphael B. wrote:

On 11/28/05, Dan W. removed_email_address@domain.invalid wrote:

/articles/whatever instead of /blog/articles/whatever. Does anyone
know of a way around this or even an alternative set up which might
work. I would even consider moving the PHP portion of the site over
if that makes it easier. Any wisdom on this? Ive ploughed through
all the wiki and other articles on the subject but found no solution
as yet.

Use
ProxyPass /blog http://blog.myorg.net:8080
ProxyPassReverse /blog http://blog.myorg.net:8080

You’ll probably also need the (brand-new) strip-request-uri option in
lighttpd, discussed here:

http://blog.lighttpd.net/articles/2005/11/23/lighttpd-1-4-8-and-multiple-rails-apps

Seems to be the moral equivalent of RewriteBase in apache.

Chris.


#4

Thanks very much, I’ll try that. I’ve been trying to use
proxypassreverse but to know avail so far.

What does proxypassreverse do exactly? Does it just fix the redirects?

Thanks,

Dan

On 11/28/05, Chris A. removed_email_address@domain.invalid wrote:

ProxyPass /blog http://blog.myorg.net:8080

Chris.


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


Dan W.
http://www.danwebb.net


#5

Hi,

After some reading of actionpacks source code I came up with a really
nice solution to this problem (and other related problems) so I
thought I’d post here for anyone else who might be interested. In one
of the environment files add:

ActionController::AbstractRequest.relative_url_root = “/blog”

where /blog is the directory your rails app will work under. This
causes Routes and all the url helpers to work correctly under lighty
(on apache action pack works this out for itself).

Thanks,


Dan W.
http://www.danwebb.net


#6

Dan W. wrote:

Thanks very much, I’ll try that. I’ve been trying to use
proxypassreverse but to know avail so far.

What does proxypassreverse do exactly? Does it just fix the redirects?

Yeah, that’s it. The important part of the fix is the lighttpd option
though – I think you can successfully use either the mod_rewrite or the
ProxyPass style of configuring Apache.

Chris.