more_set_headers"Server: Web Server"; #charset koi8-r;
#access_log logs/host.access.log main;
location / { root html; index index.html index.htm; } }
测试结果
1 2 3 4 5 6 7 8 9 10
root@elk:/etc/nginx# curl -L -I localhost HTTP/1.1 200 OK Date: Sun, 27 Mar 2022 09:03:37 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Tue, 06 Jul 2021 14:59:17 GMT Connection: keep-alive ETag: "60e46fc5-264" Server: Web Server Accept-Ranges: bytes
添加状态码404 响应header
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
server { listen80; server_name localhost;
more_set_headers"Server: Web Server"; more_set_headers -s 404"Error: Please Go Home Not found"; #charset koi8-r;
#access_log logs/host.access.log main;
location / { root html; index index.html index.htm; } }
测试结果
1 2 3 4 5 6 7 8
root@elk:/etc/nginx# curl -L -I localhost/b HTTP/1.1 404 Not Found Date: Sun, 27 Mar 2022 09:09:02 GMT Content-Type: text/html Content-Length: 153 Connection: keep-alive Server: Web Server Error: Please Go Home Not found
4.隐藏Content-Type
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
server { listen80; server_name localhost;
more_set_headers"Server: Web Server"; more_set_headers -s 404"Error: Please Go Home Not found"; more_clear_headers"Content-Type:"; #charset koi8-r;
#access_log logs/host.access.log main;
location / { root html; index index.html index.htm; } }
测试结果
1 2 3 4 5 6 7
root@elk:/etc/nginx# curl -L -I localhost/b HTTP/1.1 404 Not Found Date: Sun, 27 Mar 2022 09:18:14 GMT Content-Length: 153 Connection: keep-alive Server: Web Server Error: Please Go Home Not found