访问域名不定时出现521错误

各位好,在设置我的域名的时候,我遇到了如下情况:搭好nginx之后接入了Cloudflare,初次访问可以看到默认页面,但是加载完成页面后马上刷新就会提示521错误,等待一段时间后又可以访问一次,然后再刷新又会提示521

由于还没来得及搭建网站及进行配置,我使用的是nginx默认配置文件,没有访问速率限制,而且当我使用Cloudflare worker或我本地的网络直接访问我的源站时不会出现这种情况

我没有使用iptables或者firewalld等对端口作出限制

这是我的域名:https://new.fangkehou.eu.org,请帮助我解决这个问题,谢谢!

Dear Mr./Mrs.
I have some trouble when setting my domain. I have already prepared nginx environment and started it up, and I have already used the Cloudflare CDN. It works and shows the default page of nginx at first time, but if I refresh the page the time it finished loading, it shows an 521 error. And it works again if I wait some time and repeat the situation above.
Since I have just set up nginx,so I use the default conf file of nginx,which don’t have access limit,and I won’t meet this problem if I use my network or Cloudflare worker to connect to my origin server.I’m not using iptables or firewalld to limit my server’s port either.
Here is my domain new.fangkehou.eu.org, please help me solve this problem. Thank you!

(我英语不是很好,还请您不要介意)

20210805更新:/ update on 2021.8.5:
依照了 @1blas 的建议关闭了Railgun,问题解决了,但是原因没搞明白。。。。。。
I have turn off the Railgun, thanks to @1blas . But I still don’t know why…

I can see this problem on your site. I got a 521 on my fourth load.

I know you said you do not have any access limits, and there is no problem if you use your network or Worker, but it does look like a Rate Limit.

I see @erictung is replying and may have a suggestion.

1 Like

请问本地访问速度快吗?需不需要等几秒来加载?

我通過 Cloudflare 连接的确会发现 521 错误.

有可能就如 @sdayman 所说,访问速度遭到限制。

有发现 Nginx 有出现什么错误信息吗?

那如果你把子域名的代理模式 (proxy mode) 切换成 :grey:, 问题还会出现吗?(可能不再是 521 错误,而是浏览器可能会出现其他错误)

1 Like

并不会。。。。。。本地访问时速度很快。在我本地访问灰云的域名也没有出现问题(现在已经设置成灰云了)

Now it is not letting me connect (I am in the US):

Where is your server? Which country? It may refuse some outside connections.

看來你已经切换成 :grey: 模式了

从我这里的测试,网站的连接的确有问题 - 出现 ERR_CONNECTION_REFUSED 错误。

1 Like

刚刚做了一些检查,发现到你的域名已经有启动 HSTS 预加载 (HSTS Preload),那所有 HTTP 请求就会被重定向到 HTTPS 网址。

如果我直接对伺服器 IP 发送 HTTP 请求,那基本上我就没有看到什么问题。但你的 Nginx 看起来只接受 HTTP 请求 (端口 80) 而并没有 HTTPS 支持 (端口 443)。你需要在 Nginx 设定 Virtualhost 並安裝 SSL 证书.

2 Likes

emmmmmmmmm,开了443也是一样啊,就算把这个域名的ssl设置成严格之后也还是会出现这个问题。。。。。。。。

emmmmmm。。。。。。。没有人了?。。。。。。。

自己研究了两天,还是没有解决这个问题,期间将nginx换成了tengine搭建了反向代理,但就如同之前那样,还是会出现521的问题,试过将cloudflare回源设置成严格,也试过使用其他端口,都还是会出现这种问题,但是同样的,自己访问也还是没有问题,被cloudflare缓存的资源也可以访问 :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: 。。。。。。。。。。总之我能想到的我都测试过了,但还是没有效果。。。。。。

你尝试联络客服了吗,有的话可否把票号发送到这里,或许其他客服人员可以来看下这个问题

目前我也想不出还会有什么可能性造成这个问题的发生

1 Like

。。。。。我没联系客服。。。。。我的问题只在这一个域名所在的服务器出现,我不知道如何去单独为这个域名生成支持票证,而不是整个根域名。。。

Hi there @zhangke200377,

I took a look at our logs for your zone and can see that the intermittent 521 errors that have been served are mainly due to a network connectivity issue with Railgun. Can you reach out to your hosting provider or look through your origin server logs for any Railgun errors?

Here’s this for reference: https://developers.cloudflare.com/railgun/user-guide/set-up/potential-problems

2 Likes

@1blas Oh,thanks! that really help. I have turn off the Railgun and have successfully solved the problem.But I can’t know why… There is not even an access log on my server when 521 error happens…

I never expect that Railgun was causing the issue :rofl:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.