cloudflare tunnel (https routing)+ npm + https application (all of them in docker) #3971
Replies: 4 comments 5 replies
-
Hey @hmntsharma, I'm a bit confused by your setup. Can you specify what's happening and what you expect to happen? Here's an example, based on your post: "While on a Cloudflare Zero Trust tunnel I'm connecting to https://example.com (running NPM) and I get an invalid certificate" Just a note: if your apps are running isolated in the docker network (they don't receive requests from a public net, such as the internet) it's less complex and error-prone to use http to communicate with NPM and have NPM deal with https. |
Beta Was this translation helpful? Give feedback.
-
I have a domain, say hmntsharma.com, DNS handled by Cloudflare. On my RPi4, I connect the Cloudflare zero trust tunnel using docker. I have got npm (docker, exposing public HTTP, HTTPS, and the Webadmin port to the host) and AdguardHome(docker not exposing any ports to the host) running on the same Pi and the same docker bridge. On the npm, I have two sets of certs: one is via Let's Encrypt using Cloudflare DNS challenge, and the other is manually uploaded to it, which is created on the Cloudflare origin certs. I have configured the proxy hosts on the npm to point to the HTTPS port of the AdguardHome IP:Port, using the certs. To reach adguard.hmntsharma.com online, the request goes to cloudflare and cloudlfare presents its universal cert to the visitor, cloudflare then makes the connection to the RPi server, which in this case is the NPM proxy and the webpage opens. This works! As soon as I change the cloudflare public hostname from HTTP to HTTPs and the public HTTPS port of the NPM (with no TLSverify option on Cloudflare), it does not work. If I bypass NPM, expose the adguardhome ports to the host and then configure cloudflare to point to the RPi host IP and adguardhome exposed HTTPS port (with no TLSverify option on Cloudflare), it also works. In short. Visitor ---HTTPS(cloudflare universal cert)----> Cloudflare ---Cloudflare tunnel using HTTP---> NPM ---HTTPS----> AdguardHome. | **This works ** But Visitor ---HTTPS(cloudflare universal cert)----> Cloudflare ---Cloudflare tunnel using HTTPS---> NPM ---HTTPS----> AdguardHome. | This does not I installed tcpdump on the npm docker container and I can see the traffic hitting the container but not sure why the page does not open. Kindly let me know if you need more information on this. |
Beta Was this translation helpful? Give feedback.
-
The last few weeks were busy, but I got back to it tonight and here is what I have found. The NPM does not respond at the application level on port 443. The files But, it does receive the traffic as captured below.
Another service on port 80 works just fine. It routes to https service.
Cloudlfare sends the request for both it seems, HTTP and HTTPS but NPM does not respond for HTTPS the same way as it does for HTTP. |
Beta Was this translation helpful? Give feedback.
-
@hmntsharma I solved the problem with the latest version I made these changes and tried with Authelia and it works. Surely there will be other changes to make, but now it doesn't give any errors and WebAuthn also works correctly Generate a Self-Signed Certificate using OpenSSLlocalhost.conf
Create the Certificate using OpenSSL
New default.conf
Docker Compose (add this, on NPM)
Cloudflare Tunnel (config.yml)
NPM Proxy Setup![]() ![]() ![]() ![]() Cloudflare Setup![]() ![]() NPM Proxy Advanced (for host protected from authelia)![]() |
Beta Was this translation helpful? Give feedback.
-
Hello,
Has anyone had success with cloudflare zero trust tunnel (docker) with public hostname routing https to npm (docker) to another application (docker).
I can get the HTTP working but not https
If I bypass npm and configure the https routing on cloudflare directly for the application, it works but npm can only proxy HTTP.
I have tried let's encrypt and cloudflare origin certs both, in fact, in installed iproute2 and tcpdump to capture traffic on the npm docker
and I see the traffic but the webpage does not open.
Please share if anyone ever tried this setup and got it working.
Thanks,
Hemant
Beta Was this translation helpful? Give feedback.
All reactions