I am running Tomcat on Ubuntu 12.10 and have a webapp installed. It works fine when accessed using Tomcat (localhost:8080/webappname). Requests to a servlet using this method appear in the Tomcat access log as /webappname/servlet/servletname. However, I would prefer to host the static http files using apache httpd instead. Thus, I installed and configured mod_jk.
The problem is that requests from the httpd server show up in the Tomcat log /servlet/servletname, missing the webapp name in front, and thus returning 404.
I tried adding:
RewriteEngine On
RewriteRule ^/servlet/(.*)& /webappname/servlet/$1 [PT]
to apache's virtual host config, but this did not work. I don't know if rewrites are passed on to mod_jk.
What is the best way to tackle this problem? Should the request be rewritten in the httpd server, or is there a way to tell Tomcat to forward the request to a specific webapp?
Edit:
These lines are in the virtual host config:
JkMount /servlet/ ajp13
JkMount /servlet/* ajp13
This is the config file for mod_jk:
<IfModule jk_module>
JkWorkersFile /etc/apache2/jk_workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel info
JkShmFile /var/log/apache2/jk-runtime-status
JkWatchdogInterval 60
<Location /jk-status>
# Inside Location we can omit the URL in JkMount
JkMount jk-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
<Location /jk-manager>
# Inside Location we can omit the URL in JkMount
JkMount jk-manager
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
Here is the workers properties file:
worker.list=ajp13
worker.ajp13.type=ajp13
worker.ajp13.host=localhost
worker.ajp13.port=8009
worker.ajp13.lbfactor=50
worker.ajp13.cachesize=10
worker.ajp13.cache_timeout=600
worker.ajp13.socket_keepalive=1
worker.ajp13.socket_timeout=300
max_packet_size=65536
You need to use:
JkMount /webappname/servlet/ ajp13
JkMount /webappname/servlet/* ajp13
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.