# Lighttpd and Apache .. will they play together?

**URL:** <https://www.ruby-forum.com/t/lighttpd-and-apache-will-they-play-together/72891>\
**Category:** Rails\
**Created:** [February 24, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/lighttpd-and-apache-will-they-play-together/72891 "2006-02-24T17:18:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [February 24, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/lighttpd-and-apache-will-they-play-together/72891/1 "2006-02-24T17:18:09Z")

</div>

Can someone point me to a tutorial or web example of doing this …

I want to have a site that is normally pure content served via Apache  
and I  
want to set up a Rails app on the same box that is served via lighttpd.  
Now  
I want the Apache site to be able to retrieve formatted pages for MySQL  
database queries by the Rails app. I will also be using ActionMailer  
under  
the Rails app.

How can I get those two things to work together. The Apache server  
talks to  
the default port 80 and I have the lighttpd talking to another port on  
the  
same machine. The port that lighttpd talks to is not open to the  
Firewall  
but can be reached with localhost:XXXX.

All comments welcome  
john

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [February 24, 2006, 5:24pm UTC](https://www.ruby-forum.com/t/lighttpd-and-apache-will-they-play-together/72891/2 "2006-02-24T17:24:13Z")

</div>

On 2/24/06, John N. Alegre [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> same machine. The port that lighttpd talks to is not open to the Firewall  
> but can be reached with localhost:XXXX.

[http://wiki.rubyonrails.org/rails/pages/HowToInstallLighttpdOnFreeBsdViaProxyPassThroughFromApache](http://wiki.rubyonrails.org/rails/pages/HowToInstallLighttpdOnFreeBsdViaProxyPassThroughFromApache)

I have no idea if this actually works or not, but I’ve been doing some  
reading because I have the exact situation coming up soon. (i.e. PHP  
apps running behind Apache virtual hosts, with the need to add  
lighttpd+Rails on a new virtual host on the same box)

– James

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [February 24, 2006, 6:03pm UTC](https://www.ruby-forum.com/t/lighttpd-and-apache-will-they-play-together/72891/3 "2006-02-24T18:03:47Z")

</div>

James L. wrote:

> On 2/24/06, John N. Alegre [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > How can I get those two things to work together. The Apache server talks to  
> > the default port 80 and I have the lighttpd talking to another port on the  
> > same machine. The port that lighttpd talks to is not open to the Firewall  
> > but can be reached with localhost:XXXX.
> 
> [http://wiki.rubyonrails.org/rails/pages/HowToInstallLighttpdOnFreeBsdViaProxyPassThroughFromApache](http://wiki.rubyonrails.org/rails/pages/HowToInstallLighttpdOnFreeBsdViaProxyPassThroughFromApache)
> 
> I have no idea if this actually works or not, but I’ve been doing some  
> reading because I have the exact situation coming up soon.

Yes, the Apache config on that HowTo page will work just fine. I’m not  
sure I  
fully agree with the use of RewriteEngine, when ProxyPass should work  
just fine,  
with less memory impact on your Apache processes, but if you need to  
send any  
custom HTTP headers in to your Rails app, from the Apache side, then  
mod\_rewrite  
is what you need to use.

This is what I do, using a really nice writeup from James Duncan  
Davidson:

[http://duncandavidson.com/essay/2006/01/railsReverseProxyWithSsl](http://duncandavidson.com/essay/2006/01/railsReverseProxyWithSsl)

He’s doing Apache front-ending for his Rails apps in the same way that I  
am.

-Brian

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [February 24, 2006, 8:32pm UTC](https://www.ruby-forum.com/t/lighttpd-and-apache-will-they-play-together/72891/4 "2006-02-24T20:32:48Z")

</div>

On Feb 24, 2006, at 8:24 AM, James L. wrote:

> > ActionMailer under  
> > [http://wiki.rubyonrails.org/rails/pages/](http://wiki.rubyonrails.org/rails/pages/)  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

```
Here is an example of the apache vhosts I use to do this same thing.

```

One for apache 1.3 and one for 2.X.:

[http://brainspl.at/articles/2005/11/08/apache-vhost-to-proxy-thru-to-](http://brainspl.at/articles/2005/11/08/apache-vhost-to-proxy-thru-to-)  
lighttpd-on-a-higher-port

```
You will need to do some fiddling if you want to proxy not

```

everything but just a few urls.

Cheers-  
-Ezra Z.  
Yakima Herald-Republic  
WebMaster

> **[yakimaherald.com | Yakima, Washington - We Tell Your Stories](https://www.yakimaherald.com/)**

509-577-7732  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [February 24, 2006, 7:47pm UTC](https://www.ruby-forum.com/t/lighttpd-and-apache-will-they-play-together/72891/5 "2006-02-24T19:47:27Z")

</div>

Brian,

Thanks for the pointers.

Considering the Apache problems with FastCGI and the issue of drag  
with a relaunch of the Ruby interpreter for each CGI call it would be  
my opinion that for a small App doing what we are talking about here,  
i.e. running the Rails app under lighttpd and have Apache talk to it  
would be pretty common.

On another note. What would be the issues changed if lighttpd was on  
another box on the same LAN ??

Thanks for your continued comments.

john
