我们在 Ubuntu 上使用 apache2 后面的 tomcat 6.0.29。 jsp 页面呈现为纯文本而不是呈现为 html(我在浏览器窗口中看到了整个 html),如果我直接通过 tomcat 实例访问实例,一切正常。
我正在使用 mod_proxy_ajp,我也尝试过使用 mod_proxy_http。但没有运气。
使用 Dev Tools 检查 chrome 浏览器中的内容类型。如果我访问 Web 服务器 (http://www.myserver.com),则类型为“text/plain”,如果我访问 tomcat (http://www.myserver.com:8080),则类型以“text/html”形式出现,页面正确呈现。
这是我的 apache 配置:
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
有人遇到过这种问题吗?如果是,您能否分享一下这是如何解决的?
最佳答案
在/etc/apache2/apache2.conf 中,寻找名为“DefaultType”的配置项,默认为“text/plain”。将其更改为“text/html”,重新启动 Apache,应用程序运行正常。
关于java - Tomcat 6.0.29 和 Apache2 Proxy 将渲染 text/html 作为 text/plain 传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7783234/