# Lighttpd proxy w/ apache2

**URL:** <https://www.ruby-forum.com/t/lighttpd-proxy-w-apache2/49728>\
**Category:** Rails\
**Created:** [December 8, 2005, 4:41am UTC](https://www.ruby-forum.com/t/lighttpd-proxy-w-apache2/49728 "2005-12-08T04:41:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [December 8, 2005, 4:41am UTC](https://www.ruby-forum.com/t/lighttpd-proxy-w-apache2/49728/1 "2005-12-08T04:41:29Z")

</div>

I’ve tried a bunch of things trying to get ruby/apache2 and php working  
together. I looked over my earlier post and followed the instructions  
on ezra’s website to install lighttpd on debian. I’ve gotten really far  
but I think there is one bit missing:

1. I got apache2 and php working together
2. I got lighttpd working on port 3000 and my rails app launches ok  
there

So at this stage, both PHP and Ruby are on the same server except that  
ruby is on port 3000 while the rest is going on port 80.

1. I copied/pasted this vhost section into my apache2/sites-enabled  
folder in order to pass the sites that will be using ruby to lighttpd

\<VirtualHost \*:80\>  
ServerName [example.com](http://example.com)  
ServerAlias [www.example.com](http://www.example.com)  
#ProxyPreserveHost on #\<-apache2 only  
ProxyPass / [http://example.com:8000/](http://example.com:8000/)  
ProxyPassReverse / [http://example.com:8000/](http://example.com:8000/)

changing the [example.com](http://example.com) to my URL.

1. I got an error so I used a2enmod proxy. Stopped and restarted apache2
2. After doing that when I go to my URL I get a 403 error: Forbidden

In fact, I can’t go to any IP/URL on that server without seeing a 403.  
So even the PHP stuff broke at that stage.

It’s linked to the ProxyPass statements somehow. I’ve tried messing  
with proxy.conf in my apache2/mods-enabled folder but that didn’t seem  
to do anything.

I also changed lighttpd.conf to run on port 8000 in case that was the  
error but that also didn’t change anything.

So now I’m at the stage where if I keep the proxy module I get the 403  
error and if I don’t I can get to my PHP stuff, but can’t get to my  
rails app.

Is there some last step I’m missing?

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [December 8, 2005, 7:55pm UTC](https://www.ruby-forum.com/t/lighttpd-proxy-w-apache2/49728/2 "2005-12-08T19:55:48Z")

</div>

On Dec 7, 2005, at 7:41 PM, Vince W. wrote:

> there  
> #ProxyPreserveHost on #\<-apache2 only  
> ProxyPass / [http://example.com:8000/](http://example.com:8000/)  
> ProxyPassReverse / [http://example.com:8000/](http://example.com:8000/)

I use apache 1.3.x so the vhost was mainly for that version. But  
after taking a look to see what the preferred way to do this on  
apache2 is I cam up with this that is better for apache2:

\<VirtualHost _:80\>  
ServerAdmin removed\_email\_address@domain.invalid  
ServerName [example.com:80](http://example.com:80)  
ProxyRequests Off  
ProxyPreserveHost On  
RewriteEngine On  
RewriteRule ^/(._) [http://127.0.0.1:3000/$1](http://127.0.0.1:3000/$1) [P,L]  
ProxyPassReverse / [http://127.0.0.1:3000/](http://127.0.0.1:3000/)

HTH-  
-Ezra Z.  
Yakima Herald-Republic  
WebMaster  
[http://yakimaherald.com](http://yakimaherald.com)  
509-577-7732  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [December 9, 2005, 1:24pm UTC](https://www.ruby-forum.com/t/lighttpd-proxy-w-apache2/49728/3 "2005-12-09T13:24:46Z")

</div>

On 08/12/05, Ezra Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > \<VirtualHost \*:80\>  
> > ServerName [example.com](http://example.com)  
> > ServerAlias [www.example.com](http://www.example.com)  
> > ProxyPass / [http://example.com:8000/](http://example.com:8000/)  
> > ProxyPassReverse / [http://example.com:8000/](http://example.com:8000/)

> I use apache 1.3.x so the vhost was mainly for that version. But  
> after taking a look to see what the preferred way to do this on  
> apache2 is I cam up with this that is better for apache2:

Sorry, how is that better? You’re just using mod\_rewrite to do the  
same thing as the ‘proxypass’ directive.

> \<VirtualHost _:80\>  
> ServerAdmin removed\_email\_address@domain.invalid  
> ServerName [example.com:80](http://example.com:80)  
> ProxyRequests Off  
> ProxyPreserveHost On  
> RewriteEngine On  
> RewriteRule ^/(._) [http://127.0.0.1:3000/$1](http://127.0.0.1:3000/$1) [P,L]  
> ProxyPassReverse / [http://127.0.0.1:3000/](http://127.0.0.1:3000/)

–  
Rasputin :: Jack of All Trades - Master of Nuns  
[http://number9.hellooperator.net/](http://number9.hellooperator.net/)

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [December 9, 2005, 7:09pm UTC](https://www.ruby-forum.com/t/lighttpd-proxy-w-apache2/49728/4 "2005-12-09T19:09:39Z")

</div>

On Dec 9, 2005, at 4:23 AM, Dick D. wrote:

> > after taking a look to see what the preferred way to do this on  
> > RewriteEngine On  
> > RewriteRule ^/(.\*) [http://127.0.0.1:3000/$1](http://127.0.0.1:3000/$1)  
> > [P,L]  
> > ProxyPassReverse / [http://127.0.0.1:3000/](http://127.0.0.1:3000/)

Well the only reason it is better is that it works while the old way  
doesn’t 😉 So thats good enough for me.

Cheers-

-Ezra Z.  
Yakima Herald-Republic  
WebMaster  
[http://yakimaherald.com](http://yakimaherald.com)  
509-577-7732  
removed\_email\_address@domain.invalid
