# Rails on lighttpd through proxy

**URL:** <https://www.ruby-forum.com/t/rails-on-lighttpd-through-proxy/48997>\
**Category:** Rails\
**Created:** [November 28, 2005, 1:51pm UTC](https://www.ruby-forum.com/t/rails-on-lighttpd-through-proxy/48997 "2005-11-28T13:51:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [November 28, 2005, 1:51pm UTC](https://www.ruby-forum.com/t/rails-on-lighttpd-through-proxy/48997/1 "2005-11-28T13:51:56Z")

</div>

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](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](http://www.danwebb.net)

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [November 28, 2005, 2:52pm UTC](https://www.ruby-forum.com/t/rails-on-lighttpd-through-proxy/48997/2 "2005-11-28T14:52:44Z")

</div>

On 11/28/05, Dan W. [removed\_email\_address@domain.invalid](mailto: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](http://www.danwebb.net)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Use  
ProxyPass /blog [http://blog.myorg.net:8080](http://blog.myorg.net:8080)  
ProxyPassReverse /blog [http://blog.myorg.net:8080](http://blog.myorg.net:8080)

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

Raph

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [November 28, 2005, 3:25pm UTC](https://www.ruby-forum.com/t/rails-on-lighttpd-through-proxy/48997/3 "2005-11-28T15:25:16Z")

</div>

Raphael B. wrote:

> On 11/28/05, Dan W. [removed\_email\_address@domain.invalid](mailto: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](http://blog.myorg.net:8080)  
> ProxyPassReverse /blog [http://blog.myorg.net:8080](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](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.

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [November 28, 2005, 4:25pm UTC](https://www.ruby-forum.com/t/rails-on-lighttpd-through-proxy/48997/4 "2005-11-28T16:25:56Z")

</div>

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](mailto:removed_email_address@domain.invalid) wrote:

> > > 
> > 
> > ProxyPass /blog [http://blog.myorg.net:8080](http://blog.myorg.net:8080)
> 
> Chris.
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Dan W.  
[http://www.danwebb.net](http://www.danwebb.net)

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [November 28, 2005, 11:14pm UTC](https://www.ruby-forum.com/t/rails-on-lighttpd-through-proxy/48997/5 "2005-11-28T23:14:54Z")

</div>

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](http://www.danwebb.net)

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [November 28, 2005, 5:10pm UTC](https://www.ruby-forum.com/t/rails-on-lighttpd-through-proxy/48997/6 "2005-11-28T17:10:30Z")

</div>

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.
