如何更改(隐藏)Nginx服务器签名? [英] How to change(Hide) the Nginx Server Signature?
问题描述
我可以通过将server_tokens选项设置为off来隐藏Nginx版本。但是无法更改Nginx服务器签名。
I can hide Nginx version by using server_tokens option set to off. But not able to change the Nginx Server signature.
我所做的步骤,
1。)更改Nginx源文件中的服务器名称(src / http / ngx_http_header_filter_module.c)改为我的服务器。之后,编译nginx。但是当我加载URL时它不起作用。奇怪的是,当我使用curl命令时,可以看到更新后的签名。但是,这不会在浏览器中更新。
1.) Change the Nginx server name in source file(src/http/ngx_http_header_filter_module.c) to " My-Server". After that, compiled the nginx. But its not working when I load the url. Strange here is I can see my updated Signature when I use curl command. But this same is not updated in browser.
2。)因此,我尝试了第三方模块(headers-more-nginx-module)。这也行不通。通过Curl获取更新的名称。
2.) So I tried 3rd party module(headers-more-nginx-module). This too not working. Getting updated name via Curl. But not in Browser.
推荐答案
如果您在ubuntu中工作,则
If you are working in ubuntu then
-
首先安装
nginx-extras
sudo apt-get install nginx-extras
转到 /etc/nginx/nginx.conf
并在 http
下添加:
http {
more_set_headers "Server: Your_New_Server_Name";
server_tokens off;
}
重启nginx
Restart nginx
sudo service nginx restart
这篇关于如何更改(隐藏)Nginx服务器签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!