重定向太多 - Nginx 重定向循环
too many redirects - Nginx redirect loop
谁能看出为什么这个配置以重定向循环结束?我知道很多人都提出过类似的问题,我已经回答了几十个。我可以看到他们所有的配置哪里出了问题,但我一辈子都看不到我的问题。如果我转到 .well-known 文件夹,它会正常工作。在有人提到缓存问题之前,我已经清除了浏览器缓存和服务器缓存。我尝试了多种浏览器。还有其他想法有什么问题吗?
******.conf
server {
listen 80;
listen [::]:80;
server_name www.*******.site ******.site;
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/******.com;
}
location / {
return 301 https://www.******.site$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.******.site ******.site;
ssl_certificate /etc/letsencrypt/live/*******.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/******.site/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/******.site/chain.pem;
ssl_dhparam /etc/ssl/private/dhparam.pem;
ssl_stapling on;
ssl_stapling_verify on;
include /etc/letsencrypt/options-ssl-nginx.conf;
root /var/www/******.com;
index index.html index.php;
location / { try_files $uri $uri/ =404; }
}
选项-ssl-nginx.conf
# This file contains important security parameters. If you modify this file
# manually, Certbot will be unable to automatically provide future security
# updates. Instead, Certbot will print and log an error message with a path to
# the up-to-date file that you will need to refer to when manually updating
# this file.
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";
重定向路径
Status Code URL IP Page Type Redirect Type Redirect URL
301 http://www.*******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
根据 Richard Smith 的评论,如果您使用 -T 开关,您可以看到所有各种配置文件,这将帮助您找出问题所在。
谁能看出为什么这个配置以重定向循环结束?我知道很多人都提出过类似的问题,我已经回答了几十个。我可以看到他们所有的配置哪里出了问题,但我一辈子都看不到我的问题。如果我转到 .well-known 文件夹,它会正常工作。在有人提到缓存问题之前,我已经清除了浏览器缓存和服务器缓存。我尝试了多种浏览器。还有其他想法有什么问题吗?
******.conf
server {
listen 80;
listen [::]:80;
server_name www.*******.site ******.site;
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/******.com;
}
location / {
return 301 https://www.******.site$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.******.site ******.site;
ssl_certificate /etc/letsencrypt/live/*******.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/******.site/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/******.site/chain.pem;
ssl_dhparam /etc/ssl/private/dhparam.pem;
ssl_stapling on;
ssl_stapling_verify on;
include /etc/letsencrypt/options-ssl-nginx.conf;
root /var/www/******.com;
index index.html index.php;
location / { try_files $uri $uri/ =404; }
}
选项-ssl-nginx.conf
# This file contains important security parameters. If you modify this file
# manually, Certbot will be unable to automatically provide future security
# updates. Instead, Certbot will print and log an error message with a path to
# the up-to-date file that you will need to refer to when manually updating
# this file.
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";
重定向路径
Status Code URL IP Page Type Redirect Type Redirect URL
301 http://www.*******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
301 http://www.******.site/ 172.67.161.149 server_redirect permanent https://www.******.site/
301 https://www.******.site/ 172.67.161.149 server_redirect permanent http://www.******.site/
根据 Richard Smith 的评论,如果您使用 -T 开关,您可以看到所有各种配置文件,这将帮助您找出问题所在。