apache > lenya
 

Running Lenya Behind Apache with mod_proxy_ajp

Configuring the AJP Connector in Tomcat

The file $TOMCAT_HOME/conf/server.xml contains an AJP 1.3 connector on port 8009 by default:

<Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3"/>

If the connector is not present, you have to add it.

Configuring the Apache Web Server

Now we'll declare the virtual hosts for the Apache web server. This is done in a file called httpd-vhosts.conf. On Mac OS X, it is located in the directory /opt/local/apache2/conf/extra. The contents of the file should look like this:

NameVirtualHost *:80
NameVirtualHost *:443

# This is the non-SSL host for the authoring environment.
<VirtualHost *:80>
    ServerAdmin webmaster@cms.example.com
    ServerName cms.example.com
    ServerAlias cms

    ProxyRequests Off

    RewriteEngine On
    RewriteLog /home/john/src/www/logs/cms.example.com-rewrite_log
    RewriteLogLevel 4
    
    # Redirect the login usecase to https
    RewriteCond %{QUERY_STRING} (.*)lenya\.usecase=ac\.login(.*)
    RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]

    <Location /lenya/>
      ProxyPass ajp://localhost:8009/lenya/
      ProxyPassReverse http://cms.example.com/lenya/
    </Location>

    <Location /modules/>
      ProxyPass ajp://localhost:8009/modules/
      ProxyPassReverse http://cms.example.com/modules/
    </Location>

    <Location /default/modules/>
      ProxyPass ajp://localhost:8009/default/modules/
      ProxyPassReverse http://cms.example.com/default/modules/
    </Location>

    <Location />
      ProxyPass ajp://localhost:8009/default/
      ProxyPassReverse http://cms.example.com/default/
    </Location>

    ErrorLog /home/john/src/www/logs/cms.example.com-error_log
    CustomLog /home/john/src/www/logs/cms.example.com-access_log common
</VirtualHost>

# This is the SSL host for the authoring environment.
<VirtualHost *:443>
    ServerName cms.example.com
    ServerAlias cms

    ProxyRequests Off

    SSLEngine On
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile /home/john/pki/server.crt
    SSLCertificateKeyFile /home/john/pki/server.key

    <Location /lenya/>
      ProxyPass ajp://localhost:8009/lenya/
      ProxyPassReverse https://cms.example.com/lenya/
    </Location> 

    <Location /modules/>
      ProxyPass ajp://localhost:8009/modules/
      ProxyPassReverse https://cms.example.com/modules/
    </Location>

    <Location /default/modules/>
      ProxyPass ajp://localhost:8009/default/modules/
      ProxyPassReverse https://cms.example.com/default/modules/
    </Location>
    
    <Location />
      ProxyPass ajp://localhost:8009/default/
      ProxyPassReverse https://cms.example.com/default/
    </Location>

    ErrorLog /home/john/src/www/logs/ssl.cms.example.com-error_log
    CustomLog /home/john/src/www/logs/ssl.cms.example.com-access_log common

</VirtualHost>

# This is the non-SSL host for the live area.
<VirtualHost *:80>
    ServerAdmin webmaster@www.example.com
    ServerName www.example.com
    ServerAlias www

    ProxyRequests Off

    <Location />
      ProxyPass ajp://localhost:8009/default/live/
      ProxyPassReverse http://www.example.com/default/live/
    </Location>

    ErrorLog /home/john/src/www/logs/www.example.com-error_log
    CustomLog /home/john/src/www/logs/www.example.com-access_log common
</VirtualHost>