Forum: Ruby on Rails Rails on lighttpd through 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.
dan (Guest)
on 2005-11-28 14:51
(Received via mailing list)
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
rblists (Guest)
on 2005-11-28 15:52
(Received via mailing list)
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
chris (Guest)
on 2005-11-28 16:25
(Received via mailing list)
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/light...

Seems to be the moral equivalent of RewriteBase in apache.



Chris.
dan (Guest)
on 2005-11-28 17:25
(Received via mailing list)
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
chris (Guest)
on 2005-11-28 18:10
(Received via mailing list)
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.
dan (Guest)
on 2005-11-29 00:14
(Received via mailing list)
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
This topic is locked and can not be replied to.