nginx 使用代理传递将所有尾随 / 重写为 /index.html

LeC*_*oux 5 nginx

使用 nginx 作为反向代理,我想indexproxy_pass. 因此我希望 nginx 查询/index.html而不是/,/sub/index.html而不是/sub/.

做到这一点的最佳方法是什么?

不确定它是否相关,但代理服务器确实HTTP 200在 上应答/,但我仍然想将其重写为/index.html.

由于/请求通过列出目录内容泄漏了一些信息,我还想确保没有人能够访问它(就像做类似的事情/sub/..)。

谢谢

Max*_*x0u 5

只需添加:

rewrite (.*)/$ $1/index.html last;
rewrite (.*)/..$ $1/../index.html last;
Run Code Online (Sandbox Code Playgroud)

应该有效