你好,谢谢你帮助我。 我最近添加了一个SSL证书到我的网站。 它工作了一点,但现在我得到了浏览器中“太多的redirect循环”。 我对服务器不是很了解(我在跟随一个在线指南),所以这可能只是一个新手的错误。
这里是文件:
upstream app_server { server unix:/var/run/unicorn.sock fail_timeout=0; } server { listen 80; server_name example.com; return 301 http://www.example.com$request_uri; } server { listen 443 ssl; listen [::]:80 default ipv6only=on; root /home/example/public; server_name www.example.com; rewrite ^(.*) https://www.example.com$1 permanent; ssl_certificate /example.com.chained.crt; ssl_certificate_key /example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL; index index.htm index.html; location / { try_files $uri/index.html $uri.html $uri @app; } location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|$ try_files $uri @app; } location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } }
这是一个新秀的错误。
您已将redirect放置在https server块中:
rewrite ^(.*) https://www.example.com$1 permanent;
这只是redirect回到相同的URL。
当你删除,你应该没问题。 redirect应该只在端口80上提供http的块中,而不是在端口443上提供https的块中。