502 Error while calling localhost [self hosted nginx] on both HTTP & HTTPS

Dear Community,

I’m fairly new to Cloudflare and utilising it to consume my local hosted NGINX web Server via public internet. Have followed the documentation and have setup a tunnel with cloud flared running on docker.
My Nginx is running on Mac as a standalone web server.

Everything is working fine if I setup my Mac IP in the public hostname name section Ex: http://192.**.**.**:8080.
But if I change it to http://locahost:8080, it fails with 502.
If I change it to https, then even the IP scenariohttps://192.**.**.**:443 fails.

Seeking support in understanding Cloudflare and resolving it the right way.

Cheers.

In Docker 127.0.0.1 normally means “in this container” rather than on your local machine, unless you have already set up further networking options.

There is a somewhat-similar discussion on Stackoverlow:

As for the HTTPS failing, you very likely need to set noTLSVerify in your configuration file, at least for testing and during the initial setup as certificates are complicated and generally won’t work at all when using IP addresses unless you also set originServerName in your configuration (and even then, you actually need a trusted certificate, and possibly the trust roots to be configured).

In other words, simplify at first and use noTLSVerify to get things going initially.

1 Like