Saturday, July 27, 2013

Adding exception in mod_jk.conf using JkUnMount

Advertisements

We have seen in our older post how to connect httpd and Apache tomcat using connector mod_jk. httpd as a front end and Apache tomcat as back end. But in that configuration all the requests coming to httpd is redirected to tomcat. What if you want to load something using Apache web server itself? In this post we will see how to add exception in mob_jk using JkUnMount.

Existing mod_jk.conf
cat /etc/httpd/conf.d/mod_jk.conf
JkWorkersFile /etc/httpd/conf.d/workers.properties
JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
#below you can see that all the traffic is redirected to tomcat
JkMount /* worker1              
JkShmFile  /etc/httpd/logs/jk-runtime-status


Now suppose we add another virtual host in Apache. But it will also be redirected to tomcat by default because of the mod_jk configuration. In order to prevent this we can use JkUnMount parameter. It will prevent Apache forwarding the request to tomcat and serving by httpd itself.

<VirtualHost *:8181>
  DocumentRoot "/usr/local/google-sitemap-generator/admin-console"
  ScriptAlias /cgi-bin/ "/usr/local/google-sitemap-generator/admin-console/cgi-bin/"
  ServerName www.domain.com:8181
  JkUnMount  /* worker1 #this is the workername
  <Directory "/usr/local/google-sitemap-generator/admin-console" >
    Allow from all
    Options ExecCGI
    DirectoryIndex index.html
  </Directory>
</VirtualHost>

No comments:

Post a Comment

Be nice. That's all.