错误:内部重定向至“/index.html”时重写或内部重定向循环

错误:内部重定向至“/index.html”时重写或内部重定向循环

我在配置方面遇到了问题nginx。Docker 中一切都运行正常,但我不得不放弃 Docker,事情开始发生了变化。

500 internal server error实际上,当我尝试使用我的应用程序时,我得到了一个。

我已经复制了内容文件夹dist(而不是整个文件夹)到/usr/share/nginx/html

我的 nginx.conf 如下所示:

server {
   listen         443 ssl;
   server_name    localhost;
   ssl_certificate /usr/share/nginx/cert.pem;
   ssl_certificate_key /usr/share/nginx/key.pem;
   # add Strict-Transport-Security to prevent man in the middle attacks
   add_header Strict-Transport-Security "max-age=31536000" always;

  root   /usr/share/nginx/html;
  index  index.html index.htm;
  include /etc/nginx/mime.types;

  gzip on;
  gzip_min_length 1000;
  gzip_proxied expired no-cache no-store private auth;
  gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

  location / {
    try_files $uri /index.html;
  }

  location /api {
        proxy_pass http://localhost:8080/api;
        proxy_set_header Host $host;
        proxy_redirect          off;
        proxy_set_header        X-NginX-Proxy true;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

我收到的错误是:

2019/07/09 16:32:42 [error] 7539#7539: *13 rewrite or internal 
redirection cycle while internally redirecting to "/", client: 
172.18.34.217, server: localhost, request: "GET / HTTP/1.1", host: 
"172.17.63.62"

我究竟做错了什么?

我在 serverfault 上搜索过许多类似问题,但没有找到任何可以解决我的问题的东西……

编辑:

我还发现了另一个错误:

stat() "/usr/share/nginx/html/index.html" failed (13: Permission 
denied), client: 172.18.34.217, server: localhost, request: "GET 
/index.html HTTP/1.1", host: "172.17.63.62"

我应该为文件设置什么权限?

实际上它们看起来像这样(只是一个例子,文件列表更长):

-rw-r--r--. 1 user user  12K 07-09 16:22 index.html
drwxr-xr-x. 3 user user   17 07-09 16:22 assets

相关内容