Nginx“在内部重定向到“/index.html”时重写或内部重定向循环”

Nginx“在内部重定向到“/index.html”时重写或内部重定向循环”

我在 Ubuntu 服务器上安装了大量的 LEMP,只是为了托管一些静态文件。

当仅出于测试目的设置 PHPNuke 时,我注意到我没有安装 GD 支持。我使用 php5-fpm 设置了 nginx,因此运行“apt-get install php5-gd”来安装 GD 支持库。但之后,nginx 崩溃了。卸载 php5-gd 也没有解决问题。我在 nginx 中收到错误 500,错误日志显示以下内容:

2013/01/23 13:27:45 [debug] 16943#0: *16 http script var: "/index.html"
2013/01/23 13:27:45 [debug] 16943#0: *16 trying to use dir: "/index.html" "/etc/nginx/html/index.html"
2013/01/23 13:27:45 [debug] 16943#0: *16 trying to use file: "/index.html" "/etc/nginx/html/index.html"
2013/01/23 13:27:45 [error] 16943#0: *16 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 10.2.1.1, server: localhost, request: "GET$
2013/01/23 13:27:45 [debug] 16943#0: *16 http finalize request: 500, "/index.html?" a:1, c:12
2013/01/23 13:27:45 [debug] 16943#0: *16 http special response: 500, "/index.html?"
2013/01/23 13:27:45 [debug] 16943#0: *16 http set discard body
2013/01/23 13:27:45 [debug] 16943#0: *16 xslt filter header
2013/01/23 13:27:45 [debug] 16943#0: *16 HTTP/1.1 500 Internal Server Error

不知道为什么会发生这种情况,我的配置根本没有引用 /etc/nginx/html,所以不知道为什么它会尝试在这个目录中查找文件。以下是我的配置:

http://pastie.org/private/ynrprqgelt10nfzexvsqtq http://pastie.org/private/2dnldzpjckfky0thdqlwa

答案1

刚刚遇到了同样的错误,基本上你需要指定 index.html 的路径。你可能会遇到类似

try_files /index.html;

尝试

try_files $uri/index.html;

或者

try_files /var/www/yourpath/index.html;

您需要将目录结构更改为您现有的目录结构。之后 - 重新加载 nginx。确保您重新加载正确的进程 :) 在 ubuntu 上升级 nginx 后,我遇到了一些问题。

相关内容