There's an option to hide the version so it will display only nginx, but is there a way to hide that too so it will not show anything or change the header?
相关问题
- PHP Empty $_POST
- How can I prevent my Shiny App from disconnecting
- Can't configure nginx as a proxy for tomcat wi
- How to set Nginx URI to fix empty URI in redirect
- Extract Location from Response Header with JMeter
After I read Parthian Shot's answer, I dig into
/usr/sbin/nginx
binary file. Then I found out that the file contains these three lines.Basically first two of them are meant for
server_tokens on;
directive (Server version included). Then I change the search criteria to match those lines within the binary file.After I dig farther I found out that the error message produced by nginx is also included in this file.
There are three of them, one without the version, two of them included the version. So I run the following command to replace nginx string within the error message.
Like Apache, this is a quick edit to the source and recompile. From Calomel.org:
March 2011 edit: Props to Flavius below for pointing out a new option, replacing Nginx's standard HttpHeadersModule with the forked HttpHeadersMoreModule. Recompiling the standard module is still the quick fix, and makes sense if you want to use the standard module and won't be changing the server string often. But if you want more than that, the HttpHeadersMoreModule is a strong project and lets you do all sorts of runtime black magic with your HTTP headers.
The last update was a while ago, so here is what worked for me on Ubuntu:
Then add the following two lines to the
http
section ofnginx.conf
, which is usually located at /etc/nginx/nginx.conf:Also, don't forget to restart nginx with
sudo service nginx restart
.It’s very simple: Add these lines to server section:
The only way is to modify the file src/http/ngx_http_header_filter_module.c . I changed nginx on line 48 to a different string.
What you can do in the nginx config file is to set server_tokens to off. This will prevent nginx from printing the version number.
To check things out, try curl -I http://vurbu.com/ | grep Server
It should return
If you are using nginx to proxy a back-end application and want the back-end to advertise its own
Server:
header without nginx overwriting it, then you can go inside of yourserver {…}
stanza and set:That will convince nginx to leave that header alone and not rewrite the value set by the back-end.