现在的漏扫设备有时是实在没东西可扫了。但是不扫个毛病出来似乎就显得自己无能了。
所以,nginx和tomcat等所有WEB容器的官方404和50x报错也被奇葩的漏扫设备设为危险漏洞。
本文旨在解决上述问题。
假定有以下Tomcat和Nginx整合,以linux为例。
1.WEB根目录为 /home/portal/public_html。
2.Nginx配置文件为/usr/local/nginx/conf/nginx.conf。
3.Tomcat配置文件位于 /home/portal/conf/下。
4.web.xml位于/home/portal/public_html/WEB-INF/下。
5.在/home/portal/public_html有404.xml和50x.xml。
6.Tomcat服务已被设为portal.service
配置方法如下:
A.在/usr/local/nginx/conf/nginx.conf中server配置中加入:
error_page 500 502 503 504 /50x.html; error_page 400 401 402 403 404 /404.html; location = /404.html { root /home/portal/public_html; } location = /50x.html { root /home/portal/public_html; }B.重启nginx
---centos 7-- systemctl restart nginx.service ---centos 6-- service nginx restartC.修改/home/portal/public_html/WEB-INF/web.xml、在最末</web-app>前加入以下配置
<error-page> <error-code>404</error-code> <location>/404.html</location> </error-page> <error-page> <error-code>500</error-code> <location>/50x.html</location> </error-page>重启Tomcat
---centos 7-- systemctl restart portal.service ---centos 6-- service portal restart
测试完成。