我有一個安裝了 nginx 1.12.0 的 ubuntu 伺服器,我想完全刪除伺服器回應標頭
Server:nginx
如果我安裝 nginx-extras 它將安裝 nginx/1.1.19 版本,並且還將停用 Etags,是否有其他選項可以刪除伺服器標頭
答案1
將其添加server_tokens off;
到您的nginx.conf
伺服器下部分。
這將刪除Server: nginx 1.12.0
伺服器標頭
更新:
您需要從原始程式碼編譯它。這是關聯我從 DO 得到的。
下載 nginx 包,然後按照以下步驟操作:
cd ~/src/nginx/
vi +49 src/http/ngx_http_header_filter_module.c
找到以下幾行:
static char ngx_http_server_string[] = "Server: nginx" CRLF;
static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
修改為:
static char ngx_http_server_string[] = "Server: custom-server-name" CRLF;
static char ngx_http_server_full_string[] = "Server: custom-server-name" CRLF;
這
答案2
您必須對 nginx 進行商業訂閱,才能使用伺服器令牌「字串」從回應正文中刪除 nginx