Search code examples
apachemod-jk

Setting up Apache mod_jk in ssl VirtualHost


I'm having problems moving my Apache mod_jk configuration form its own VirtualHost configuration into my main ssl VirtualHost configuration.

Tomcat is working ok using its own domain using mod_jk and a VirtualHost configuration - working config....

LoadModule jk_module  /etc/httpd/modules/mod_jk.so
JkWorkersFile /etc/httpd/conf.d/workers.properties
JkShmFile     /var/log/httpd/mod_jk.shm
JkLogFile     /var/log/httpd/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

<VirtualHost *:80>
    ServerName <my cname>
    DocumentRoot /opt/appserver/webapps/ROOT
    DirectoryIndex index_page.jsp       

    <Directory />
                Options FollowSymLinks
                AllowOverride None
    </Directory>

    <Directory /opt/appserver/webapps/ROOT>
                AllowOverride None
                Options FollowSymLinks
                Order allow,deny
                allow from all
    </Directory>

    JkMount /* ajp13
</VirtualHost>

however because I want to embed my Tomcat forms in my main server pages which are ssl (can't mix http and https) I need to move my mod_jk configuration into my main ssl VirtualHost as a subfolder. I've tried the following changes, but I get a Tomcat error 'HTTP Status 404 - /servlet/' when trying to access https://

New server config:

<VirtualHost _default_:443>

...lots of my main ssl server config stuff...

Alias /servlet /opt/appserver/webapps/ROOT

JkMount /servlet/* ajp13

<Directory /opt/appserver/webapps/ROOT>
        AllowOverride None
        Options FollowSymLinks
        Order allow,deny
        allow from all
        DirectoryIndex index_page.jsp
</Directory>

</VirtualHost>

Solution

  • This turned out to be an Apache Alias problem. Actually I couldn't get mod_jk to work with an Apache Alias, so I placed the Tomcat content in the Apache DirectoryRoot (the original config but with ssl turned on) and used:

    SetEnvIf Request_URI "/content/*" no-jk
    Alias /content /path/to/content
    

    to enable the non-Tomcat content. Readers should also check (if they're using this technique) that they have added 'RewriteBase /content' to their .htaccess file.