【发布时间】:2021-06-27 06:43:14
【问题描述】:
我有以下位置的 nginx 配置:
location /some/path- {
limit_except GET { deny all; }
proxy_pass http://my_app;
}
location / {
deny all;
}
我只允许对 /some/path- 的 GET/HEAD 请求。
我需要对/some/path- 的所有请求,这些请求在后端都是无效路径,以返回 nginx 的 404.html 而不是后端。
位置好: http://some/path-exists
位置不好: http://some/path-doesnt-exist
当我尝试添加时:
proxy_intercept_errors on;
和
error_page 404 /404.html;
当浏览到错误位置时,我似乎得到 403 Forbidden 而不是 nginx 404.html 页面。我不明白为什么。
【问题讨论】:
-
你有一个
deny all。尝试添加location = /404.html {} -
它不起作用..我浏览some/path-doesnt-exist时仍然得到403@
标签: nginx nginx-location