Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更改NginX中的服务器签名_Nginx_Http Headers - Fatal编程技术网

更改NginX中的服务器签名

更改NginX中的服务器签名,nginx,http-headers,Nginx,Http Headers,我想在Nginx的HTTP 400 Error HTML Error page footer中隐藏服务器签名。实现模块后。请求HTTP包时,服务器签名会发生更改: >> curl -I localhost 输出 HTTP/1.1 301 Moved Permanently Content-Type: text/html Content-Length: 162 Connection: keep-alive Location: https://www.abshnb.com/ Serve

我想在Nginx的HTTP 400 Error HTML Error page footer中隐藏服务器签名。实现模块后。请求HTTP包时,服务器签名会发生更改:

>> curl -I localhost
输出

HTTP/1.1 301 Moved Permanently
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://www.abshnb.com/
Server: Abshnb

但是HTTP 400错误HTML页面仍然返回带有nginx页脚的错误页面。

这里是一个非常简单的指令示例,其中错误响应由nginx本身生成:

    server {
        listen 8888;
        server_tokens off;
        ...
        error_page 400 502 @error;

        location @error {
            default_type text/html;
            return 200 '<center><h1>$status</h1></center>';
        }

        location = /error400 {
            return 400;
        }

        location = /error502 {
            return 502;
        }
自定义错误处理程序:

$ http :8888/error400    

HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 29
Content-Type: text/html
Date: Sat, 08 Feb 2020 11:43:05 GMT
Server: nginx

<center><h1>400</h1></center>
$ http :8888/nonexistent

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Length: 162
Content-Type: text/html
Date: Sat, 08 Feb 2020 11:47:19 GMT
Server: nginx

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
默认错误处理程序:

$ http :8888/error400    

HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 29
Content-Type: text/html
Date: Sat, 08 Feb 2020 11:43:05 GMT
Server: nginx

<center><h1>400</h1></center>
$ http :8888/nonexistent

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Length: 162
Content-Type: text/html
Date: Sat, 08 Feb 2020 11:47:19 GMT
Server: nginx

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

你试过指令吗?不幸的是,nginx word在默认错误页面中是硬编码的:是的,我使用了它,但它不起作用。我试图更改的错误是400。很酷,我要尝试一下并给出反馈。它不起作用,相同的默认错误页面不断出现