nginx服务器上的指向index.html的奇怪的redirect问题

我正在尝试使用nginx部署单页面应用程序,这里是下面的configuration。

server { listen 24670 default_server; listen [::]:24670 default_server; server_name *******; root /home/gerry/client/dist; index index.html index.htm; location / { try_files $uri /index.html; } } 

每当我尝试访问该页面,我会得到一个500内部服务器错误,并在检查日志,我会看到以下错误。

 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [crit] 8752#8752: *2 stat() "/home/gerry/client/dist/index.html" failed (13: Permission denied), client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 2017/10/15 18:20:17 [error] 8752#8752: *2 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 183.83.241.76, server: app.url.com, request: "GET / HTTP/1.1", host: "app.url.com:24670" 

我已经将权限和所有权设置为www-data,并且不知道还需要为index.html文件提供什么服务

根本问题是权限问题,请检查运行服务器的用户是否可以访问index.html(整个path)。

redirect是由try_files指令引起的,添加一个404作为一个catchall最后尝试停止它,即使在错误的情况下。