如何在Nginx配置中禁用server_tokens项

nginx配置中禁用server_tokens项

server_tokens在打开的情况下会使404页面显示Nginx的当前版本号。这样做显然不安全,因为黑客会利用此信息尝试相应Nginx版本的漏洞。

只需要在nginx.conf中http模块设置server_tokens off即可,例如:

server { listen 192.168.0.25:80; Server_tokens off; server_name tecmintlovesnginx.com www.tecmintlovesnginx.com; access_log /var/www/logs/tecmintlovesnginx.access.log; error_log /var/www/logs/tecmintlovesnginx.error.log error; root /var/www/tecmintlovesnginx.com/public_html; index index.html index.htm; }

重启Nginx后生效

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享