Implementing HTTPS via Custom Ports with Cloudflare Proxy

I am attempting to use Cloudflare as a proxy to enable HTTPS communication between clients and Cloudflare, while maintaining HTTP between Cloudflare and my server. My objective is to allow clients to access the server via https://url:port. However, I have encountered some issues and have a few questions:

  1. When using HTTP, I can directly access the server using a custom port, such as http://url:1314. This works seamlessly.
  2. However, when I switch to HTTPS, it doesn’t function as expected, for example https://url:1314 is not accessible.
  3. I have configured the SSL/TLS encryption mode to “Flexible” and enabled both “Always Use HTTPS” and “Automatic HTTPS Rewrites” in the Edge Certificates settings.

Thank you for your assistance.

Cloudflare’s proxy only supports these ports…

Instead you can use subdomains for each application where you have a port, use without a port in the query, but tell Cloudflare to connect to your origin server port by using origin rules…

That will connect using HTTP to your origin even if the client uses HTTPS. Always use “Full (strict)” to ensure HTTPS client connections are encrypted end-to-end and to protect your users.

1 Like

Thanks for your help. However, I’m still confused. Port 1314 is not listed among Cloudflare’s supported HTTP ports, yet it works. Could you explain why this is the case?

It shouldn’t. Is the DNS record set to “DNS only”?

No, the setting is “Proxied”, and I can use “http://url:1314” to visit my api

1 Like

What is the URL?

just http://api.xxxx.com:1314

You’ll need to give the real name for testing.

If you don’t want to leave it here, you can put it in here and I’ll take a look…
https://cf.sjr.org.uk/tools/check
(You’ll have to leave the port off as it will reject port 1314 as not supported by Cloudflare)

[add]
Check also that you don’t have something local to you that is resolving the host to the direct IP address. Requests should return Cloudflare IP addresses.

2 Likes

I think you are right. Now I cannot visit the api, and it might be that I didn’t wait long enough for the changes in the settings to take effect. I truly appreciate your help.

1 Like

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