Cloudflare和Nginx:重定向过多

编程入门 行业动态 更新时间:2024-10-15 06:20:45
本文介绍了Cloudflare和Nginx:重定向过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试设置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:重定向过多

本文发布于:2023-11-02 00:18:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550823.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   Cloudflare   Nginx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!