我正在尝试设置NGINX和cloudflare. 我已经在Google上阅读了有关此内容的信息,但没有任何解决方案能解决我的问题.目前,我的cloudflare处于活跃状态.我删除了cloudflare中的所有页面规则,但之前没有domain和www.domain使用HTTPS.我以为这可能是导致问题的原因,所以我将其删除.这是我的default NGINX文件,目的是仅允许通过域名访问而禁止通过网站的IP值访问:
I'm trying to set up NGINX and cloudflare. I've read about this on Google but nothing solved my problem. My cloudflare is active at the moment. I removed all page rules in cloudflare but before had domain and www.domain to use HTTPS. I thought this could be causing the problem so I removed it. Here is my default NGINX file, with purpose of allowing only access by domain name and forbid access by IP value of the website:
server{ #REDIRECT HTTP TO HTTPS listen 80 default; listen [::]:80 default ipv6only=on; ## listen for ipv6 rewrite ^ $host$request_uri? permanent; } server{ #REDIRECT IP HTTPS TO DOMAIN HTTPS listen 443; server_name numeric_ip; rewrite ^ www.domain; } server{ #REDIRECT IP HTTP TO DOMAIN HTTPS listen 80; server_name numeric_ip; rewrite ^ www.domain; } server { listen 443 ssl; server_name www.domain domain; #rewrite ^ $host$request_uri? permanent; keepalive_timeout 70; ssl_certificate /ssl/is/working.crt; ssl_certificate_key /ssl/is/working.key; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; #ssl_dhparam /path/to/dhparam.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM$ ssl_prefer_server_ciphers on; add_header Strict-Transport-Security max-age=15768000; (...) more ssl configs可能会发生什么?如有需要,我会提供mroe信息...
What could be off? I'll provide mroe information if needed...
推荐答案在试用后发现这仅与Cloudflare有关.因为在转到Coudflare之前我没有重定向问题.
After tryouts found that this is only related with Cloudflare. Because I had no redirect problem before moving to Coudflare.
在我看来,这是一个简单的解决方法.选择[加密]框,然后选择完全(严格),如图中所示.
In my case was simple fix like this. Select [Crypto] box and select Full (strict) as in the image.
真的,您可以先尝试此操作,然后再执行其他操作.
Really, you can try this out first before any other actions.
更多推荐
Cloudflare和Nginx:重定向过多
发布评论