Unable to Connect to Server through Cloudflare Proxy

Hey there,

I’m having some trouble with one of my subdomains and I hope you can help.

I’ve got a setup where an A record points to my server (let’s say the IP is for this example), and I’ve got the Proxied status turned on. My goal is to serve some content over HTTPS, but the server is actually a HTTP server and it’s listening on port 9001.

I created a Page Rule to forward all incoming requests to my HTTP server. Here’s what it looks like:

  • For: https://example.mydomain.com/*
  • Forwarding URL (Status Code: 301 - Permanent Redirect)
  • To: http://example.mydomain.com:9001/$1

Also, I’ve got SSL/TLS encryption mode set to ‘Flexible’.

So, here’s the weird part. Everything works as expected when I go directly to http://example.mydomain.com:9001/.well-known/somefile.json but when I try to access it over HTTPS via https://example.mydomain.com/.well-known/somefile.json, I end up getting a “connection refused” error.

To try and figure out what’s happening, I set up a DNS-only (non-proxied) A record for a test subdomain pointing directly to my server. Guess what? Everything works perfectly when I use this test subdomain.

From all this, it seems like something’s off with the Cloudflare configuration or maybe there’s some kind of weird interaction happening with my server. Any ideas?

Thanks a lot!

Cloudflare doesn’t accept connections on port 9001, see Network ports · Cloudflare Fundamentals docs.

You can use Origin rules to connect to your origin on a different port while users use port 80 or one of the other allowed ports.

Using Flexible encryption isn’t a very good idea however. It essentially fakes end-to-end encryption to your users while still being insecure.

1 Like

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