Search code examples
javaapachetomcattomcat6mod-proxy

Tomcat 6.0.29 and Apache2 Proxy pass rendering text/html as text/plain


We are using tomcat 6.0.29 behind apache2 on Ubuntu. The jsp page is being rendered as plain text and not being rendered as html (I see the entire html in the browser window) and everything works fine if I hit the instance directly via tomcat instance.

I'm using mod_proxy_ajp and I tried it with mod_proxy_http as well. But no luck.

Checked the content type in chrome browser using Dev Tools. If I hit the web server (http://www.myserver.com), then the type comes as 'text/plain' and if I hit tomcat (http://www.myserver.com:8080), then the type comes as 'text/html' and the page renders properly.

Here is my apache configuration:

ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/

Did anyone face this kind of issue? If yes, could you please share how this was resolved?


Solution

  • In /etc/apache2/apache2.conf, look for a configuration item called “DefaultType”, which defaults to “text/plain”. Change this to “text/html”, restart Apache and the application worked just fine.

    Source: http://www.j-dimension.com/?p=28