【发布时间】:2018-04-05 03:59:17
【问题描述】:
我在使用 NGINX 中的自定义错误页面时遇到了一些问题。 首先,我尝试了这个
server {
...
location / {
if ( $request_method !~ (GET|POST) ) {
error_page 418 = @not_supported;
return 418;
}
proxy_pass http://x.x.x.x;
}
location @not_supported {
return 501;
}
error_page 501 /some_page.html;
location = /some_page.html {
root html;
}
}
如果我发送除GET 或POST 以外的任何其他内容,我会收到一个显示501 method is not implemented 的默认错误页面,以及服务器的名称和版本。
如果返回在第一个位置,则服务器返回some_page.html。
在那之后,我尝试添加recursive_error_pages,这确实帮助我提供了自定义错误页面,但它完全改变了标题(添加了我之前删除的标题)。
有人知道如何让服务器为自定义页面提供服务,并保留标题的设置吗?
谢谢。
【问题讨论】:
-
你能用例子清楚地说明你想要什么吗?
标签: linux nginx server http-headers webserver