在我的设置中,我有一个nginx服务器作为我的tomcat应用程序服务器的反向代理。 我使用proxy_pass连接到tomcat上游..
location /test { proxy_pass http://upstream1/webapp1/gateway }
现在,如果有人向我的nginx服务器http://myserver.com/test.jsp发起请求,这个请求也会被testing位置处理并传递给tomcat实例。
tomcat实例返回一个404,但是nginx没有处理这个404请求。 (我已经在nginx级别定义了404页面),而是浏览器直接从tomcat显示页面(包括tomcat版本信息和全部)。 我怎样才能阻止这个 我不想公开我的应用程序服务器的详细信息。
提前致谢
您必须告诉nginx使用proxy_intercept_errors指令拦截上游错误。
location /test { proxy_pass http://upstream1/webapp1/gateway; proxy_intercept_errors on; }