I have Nginx proxy manager installed on my server and have hosted few applications. I have used Cloudflare tunnels to expose it to internet. It was working fine for months and all of a sudden it broke.
I’m getting “Bad gateway Error code 502”. But my tunnels show healthy in the dashboard. I’m able to access the applications internally with an internal domain as well. Somebody please help me!!
This means your cloudflared is able to establish a secure connection between your origin and Cloudflare, but doesn’t mean that cloudflared is able to communicate with the service that you’ve configured.
Anyway, the best way to investigate is to check the cloudflared logs. If you installed cloudflared via dashboard, then by default logging is not enabled hence you need to manually modify the service parameters so that it can perform logging related to any errors.
However, based on my experience, if the website suddenly returns Error 502 when access from external but accessible from the internal, it might be due to expired SSL certificate in the web server (particularly, your Nginx proxy manager). If you wish to verify the issue quickly, you can enable No TLS Verify option in the tunnel public hostnames configuration (particularly, TLS)
I checked the certificate expiry and its good till august 2023 and I have turned on “No TLS Verify” when I initially configured it as they are self signed certificate. I’m not sure how to turn on logs.
Thank you for looking into my issue.
The documentation that I shared earlier guides you how to modify the existing system service configuration to add one parameter to the cloudflared startup command so it can perform error logging.
This documentation shows you what parameter to use to add logging functionality: