the further adventures of

Mike Pirnat

a leaf on the wind

« Previous Post Next Post »

In Which Apache Reverse Proxies for Twisted Running MoinMoin

I'm posting this more to remember how the heck I got it working than to be any sort of definitive reference. But some folks might find it useful...

In /etc/portage/package.keywords:

www-apps/moinmoin ~x86
www-apache/mod_proxy_html ~x86
dev-libs/libxml2 ~x86

Emerge stuff:

emerge apache2
emerge moinmoin
emerge libxml2
emerge mod_proxy_html
emerge twisted

Read a bit of Apache Week's excellent and helpful article on running a reverse proxy on Apache. Admire its usefulness.

In /etc/conf.d/apache2:

APACHE2_OPTS="-D PROXY"

(plus whatever you would have had otherwise)

In /etc/apache2/httpd.conf:

<IfDefine PROXY>
    LoadModule proxy_module                  modules/mod_proxy.so
    LoadModule proxy_connect_module          modules/mod_proxy_connect.so
    LoadModule proxy_ftp_module              modules/mod_proxy_ftp.so
    LoadModule proxy_http_module             modules/mod_proxy_http.so
    LoadFile   /usr/lib/libxml2.so
    LoadModule proxy_html_module             modules/mod_proxy_html.so
</IfDefine>

In /etc/apache2/vhosts.d/20_wiki.domain.com.conf:

<VirtualHost *:80>
    ProxyPass / http://localhost:8081/
    ServerName wiki.domain.com
</VirtualHost>

I chose to run the twisted server on 8081 because I want to play with TurboGears in the coming days, and its standalone server likes to run on 8080 by default, which is also where twistd wants to run by default. I'd rather have the next "new guy" running on its default as I play with it; that should make life slightly easier.

Follow instructions on creating a wiki instance.

Follow instructions on running Moin behind a Twisted server. Edit the mointwisted.py to have the twistd server listen on the port specified in the file in vhosts.d (in this case 8081).

Drop a nice little init.d script into /etc/init.d/mywiki:

#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: $

depend() {
        after net
}

start() {
        ebegin "Starting MyWiki (twistd)"
        /usr/share/moin/mywiki/mointwisted start
        eend $? "Failed to start MyWiki (twistd)"
}

stop() {
        ebegin "Stopping MyWiki (twistd)"
        /usr/share/moin/mywiki/mointwisted stop
        eend $? "Failed to stop MyWiki (twistd)"
}

Fire up the twistd server using the init.d script; connect to http://localhost:8081/ to verify that the wiki itself is running. Fire up apache and connect to http://wiki.domain.com/ to verify that the reverse proxy magic is happening correctly.

Rejoice!

blog comments powered by Disqus

« Previous Post Next Post »