"return 301" 在 nginx 和 aws 上的配置问题

Configuration issue with "return 301" on nginx and aws

我在 aws 上有一个 nginx 服务器 运行 ubuntu 16.04 OS。我当前的站点 SSL "return 301 https://$host$request_uri" 可以完美运行,但无法在新站点上运行。

我试过配置默认值,sites-enabled/website1.ca.conf 和 sites-enabled/website1.ca.conf

server {
server_name site2.ca www.site2.ca;
listen 80;
listen [::]:80;

return 301 https://$host$request_uri;
#return 301 https://site2.ca$request_uri;
root /var/www/vhosts/site2.ca/;
index index.html index.htm index.php;

此页面无法正常工作 site2.ca 重定向您的次数过多。 尝试清除您的 cookie。 ERR_TOO_MANY_REDIRECTS

经过几个小时的混战,我分析了 SSL 证书并意识到 Cloudflare 的默认设置使用他们的 SSL 而不是网站。

解决方案是将加密设置为完全 SSL。