我无法弄清楚为什么会发生此错误:“在 nginx.conf 中内部重定向到“/index.html”时,“重写或内部重定向循环”
user www-data; worker_processes auto; pid /run/nginx.pid;
events { worker_connections 768; # multi_accept on; }
http {
sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off;
# server_names_hash_bucket_size 64; # server_name_in_redirect off;
include /etc/nginx/mime.types; default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE #ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log;
gzip on; gzip_disable "msie6";
upstream api { server 127.0.0.1:8080; }
server { listen 0.0.0.0:80; root /open-ethereum-pool/www/dist; index index.html index.htm;
server_name localhost;
location /api { proxy_pass http://api; }
location / { try_files $uri $uri/ /index.html; }
}
}
Run Code Online (Sandbox Code Playgroud)
该问题与您的配置有关
server {
listen 0.0.0.0:80;
root /open-ethereum-pool/www/dist;
index index.html index.htm;
server_name localhost;
location /api {
proxy_pass http://api;
}
location / {
try_files $uri $uri/ /index.html;
}
}
Run Code Online (Sandbox Code Playgroud)
改变
try_files $uri $uri/ /index.html;
Run Code Online (Sandbox Code Playgroud)
到
try_files $uri $uri/ /index.html =404;
Run Code Online (Sandbox Code Playgroud)
这将确保即使index.html不在那里你也会得到 404 而不是内部重定向循环
当前,当您浏览时发生的情况如下 /index.html
它成为了
try_files /index.html /index.html/ /index.html;
Run Code Online (Sandbox Code Playgroud)
现在,如果/index.html不存在,那么您的后备选项(try_file 的最后一个参数)是/index.html. 这会创建内部重定向循环。所以创建 index.html 文件并使用 try_files 下面的方式来避免此类问题
try_files $uri $uri/ /index.html =404;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6080 次 |
| 最近记录: |