Subdomain Routing When Using Cloudflare DNS Proxy

Hello everyone,

I’m facing a challenge with my domain setup in Cloudflare and would appreciate any advice or insights from the community. I just migrated from Google Domains after their decision to sell to Squarespace

Here’s a brief overview of the issue:

Setup: My domain is configured with Cloudflare, and DNS records are proxied. I use NGINX to route subdomain traffic to specific internal IP addresses and ports.

  • Problem: When DNS proxying is enabled in Cloudflare, accessing a subdomain (like sub.example.com) leads to a generic NGINX page, not the expected content. This subdomain is supposed to route to an internal address like 192.168.1.X:XXXX.
  • Observation: Disabling DNS proxy (setting DNS to “DNS only”) resolves the issue, and the subdomain routes correctly.

I suspect this might be related to how request headers, particularly the Host header, are handled when proxied through Cloudflare. Has anyone else experienced similar issues or have suggestions on how to ensure correct header forwarding or other relevant settings in Cloudflare?

Any guidance or tips would be greatly appreciated!

Thanks in advance!

What’s your encryption mode on Cloudflare?

I just checked it’s “flexible”

Also, my nginx config :

That’s the first thing you need to fix. Set that to Full Strict. That should also fix the issue.

As simple as that ! Thank you !

Works great now

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