521 Error on single page route

I’m experiencing a weird bug related to caching with Cloudflare. I am serving static files through Nginx at the route https://example.com/static/*. This serving works as intended, even with Cloudflare caching enabled. However, for one specific file, https://example.com/static/js/subscriptions.js, I am continuously getting 521 errors. The entirety of my site is accessible to Cloudflare, EXCEPT for that singular route.

Things that ‘solve’ the problem:

I obviously don’t want to keep development mode on, and I’d prefer to not ignore caching for my javascript files.

Things I’ve done to try to fix the problem:

  • Whitelist Cloudflare IP’s on origin server
  • Purge entire cache
  • Ensuring file appears when autoindex in Nginx is on
  • File perms are fine (644, www-data)

For whatever reason https://example.com/static/css and https://example.com/img both have no issues and have never returned 521 responses. I also have other javascript files hosted under the /static/js route that work. It is ONLY subscriptions.js that fails.

I’m not sure what steps I can take to fix this. If nothing else works, I suppose I’ll keep using a page route.

When you say “continuously”, is that 100% of the time? I see you’ve done a lot of troubleshooting. What kind of allowlist is that on your server? The firewall? Is there anything in your NGINX logs? Do you have access to firewall logs?

If you can get a RayID for that request, Support should be able to track it down.
Login to Cloudflare and then contact Cloudflare Support by clicking on the Get More Help button.

I appreciate your quick response.

I am running fail2ban on my server, and I am using Cloudflare-apiv4 and my local iptables to ban clients. I have configured fail2ban to ignore all of the Cloudflare IP’s listed at IP Ranges, so I don’t think fail2ban is the problem. My Nginx logs aren’t showing trying to access subscriptions.js, either. Fail2ban logs aren’t showing anything being found/banned.

I’ve opened a ticket and I’ll see what support has to say. Thank you.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.