This is an odd problem. I have a site that is not rendering it’s code correctly. It is a Tomcat 5.0.27-2 server (I know… old) and Apache 2.0.46-77 server. We cannot upgrade them at the moment as that is a bigger change than we are allowed for now.
Anyway, here’s what happens:
Go to https://mysite.com/mysite and the JSP renders correctly
Go to https://www.mysite.com/mysite and the RAW JSP is displayed, no rendering
Go to https://1.2.3.4/mysite and you get the TomCat welcome page.
Had to use a code block as i couldn’t post an invalid IP url.
I’m sure it’s a configuration setting, but I don’t know what it could be. There is an issue that the SSL we have issued was for mysite.com and not http://www.mysite.com, but i don’t think that is what is causing it. I would be happy if I could just redirect all traffic (www.mysite.com and the IP) to mysite.com instead.
I looked at the httpd.conf file. I current have the following in the VirtualHosts:
<VirtualHost 1.2.3.4:80>
ServerName mysite.com
DocumentRoot /mysite_root/ROOT
ServerAdmin me@me.com
<Location "/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
<Location "/*/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
<Location "/*/*/*/*/*/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</VirtualHost>
I have updated the files as follows:
httpd.conf
<VirtualHost 1.2.3.4:80>
ServerName mysite.com
DocumentRoot /mysite_root/ROOT
ServerAdmin me@me.com
JkMount /*.jsp worker1
JkMount /servlet/* worker1
RewriteCond %{HTTP_HOST} ^www.mysite.com [nocase]
RewriteRule ^(.*) https://www.mysite.com/$1 [last,redirect=301]
</VirtualHost>
ssl.conf
<VirtualHost 1.2.3.4:443>
ServerName mysite.com
DocumentRoot /mysite_root/ROOT
ServerAdmin me@me.com
JkMount /*.jsp worker1
JkMount /servlet/* worker1
RewriteCond %{HTTP_HOST} ^www.mysite.com [nocase]
RewriteRule ^(.*) https://www.mysite.com/$1 [last,redirect=301]
</VirtualHost>
mod_jk.conf
LoadModule jk_module modules/mod_jk.so
<IfModule jk_module>
JkWorkersFile /etc/httpd/conf/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] "
JkWatchdogInterval 60
</IfModule>
workers.properties
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
work.worker1.port=8009
When i restart httpd, there are no errors and it sees the java_home and catalina_home
You need to make sure that your
JkMountdirectives are duplicated in all of the<VirtualHost>sections that you have inhttpd.conf. If you don’t have aJkMountfor one of the cases, then Apache httpd will serve the request instead.Your problem also indicates that you are
Aliasing a URI to your webapp’s docBase. This is not recommended technique, as it can allow remote clients to request things such as/META-INF/context.xmlor/WEB-INF/web.xmland get all kinds of great information about your webapp (database credentials, etc.).Also, Tomcat 5.0 is so painfully out of date you really need to get with the program.