mod_proxy example

29 views
Skip to first unread message

wyatt-bC

unread,
Mar 12, 2007, 11:08:24 AM3/12/07
to pylons-discuss
Before today, I had never set up a reverse proxy. I've seen it
mentioned here as a good deployment option, but I couldn't seem to
find a good, complete example. After screwing around for a while, I
think I've finally got it figured out. Here's my setup in case it
might help someone else.


I compiled Apache from source using this configuration:

./configure --enable-mods-shared='rewrite speling proxy'

This automatically added a bunch (6) of 'LoadModule proxy_* ...' lines
to my httpd.conf, but only the following seem to be necessary:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so


I put this in the top level of my httpd.conf:

========================================
ProxyRequests Off
<Proxy http://127.0.0.1:5666/*>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:5666/
ProxyPassReverse / http://127.0.0.1:5666/
========================================

Note the trailing slashes on the ProxyPass directives. Note also the
use of 127.0.0.1 instead of localhost.


This is my production.ini:

========================================
[DEFAULT]
debug = false
email_to = wy...@bycycle.org
smtp_server = 127.0.0.1
error_email_from = tripplann...@bycycle.org

[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 5666
use_threadpool = true
threadpool_workers = 10

[app:main]
# same as development.ini
========================================

Note the use of 127.0.0.1 instead of localhost for the smtp_server. In
my case, using localhost works on my dev box (Ubuntu 6.10) but not on
my production box (Fedora Core 6).


In the end, there's not much to it.


__wyatt

James Gardner

unread,
Mar 12, 2007, 1:44:19 PM3/12/07
to pylons-...@googlegroups.com
Hi wyatt,

That's exactly right. For completeness if these modules aren't already
enabled can enable them with this:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_connect

The only complication with the proxying approach occurs if you are
proxying to an application that isn't at the root URL but was written to
be served from the root URL. For example say your virtual host config
has this in:

ProxyPass /forms http://localhost:5000
ProxyPassReverse /forms http://localhost:5000

In that case you just need to tweak your development.ini with a
proxy-prefix so that it all behaves as if it is being served from /forms
even though it was written to be served from /. All the routes URLs, etc
will be automatically adjusted.

[app:main]
use = egg:Forms
filter-with = proxy-prefix
# Usual options here

[filter:proxy-prefix]
use = egg:PasteDeploy#prefix
prefix = /forms

Cheers,

James

__wyatt

unread,
Mar 13, 2007, 12:48:22 AM3/13/07
to pylons-discuss
On Mar 12, 10:44 am, James Gardner <j...@pythonweb.org> wrote:
> ...

> sudo a2enmod proxy
> sudo a2enmod proxy_http
> sudo a2enmod proxy_connect

I don't seem to need the proxy_connect module in my setup. Is it
required for anything in particular?

__wyatt

James Gardner

unread,
Mar 13, 2007, 5:11:22 AM3/13/07
to pylons-...@googlegroups.com
Actually you are right. I've disabled it and everything still works,
including my SSL setup.

Cheers,

James

Reply all
Reply to author
Forward
0 new messages