I need help understanding encrypted trafic between my services #4379
-
Hi everyone. I have a working setup using npm as a reverse proxy, but I would like to extend my understanding of what I am doing. I hope someone will be able to explain it to me. Definitions
Setup explainedUser => Cloudflare DNS => Cloudflare Tunnel => Cloudflared container in my server => Nginx Proxy Manager container in my server => My containerized apps Basically, the trafic is working this way :
Let's note that I have configured SSL for My interrogations are :
Thanks in advance ! Related questions and posts
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I got a really complete answer by FoxxMD (FoxxMD on Github) which I'll forward here to help others in need : I can't comment on anything specific about NPM since I don't use it but I can respond to a few points in your setup questions, generally, I think:
No. Encryption ends at the tunnel, before cloudflared (the tunnel application) forwards it to NPM
This is unnecessary. NPM does not need (or use) certs to handle the traffic coming from cloudflared. The traffic is unencrypted at this point. [2] The point of encryption/https/ssl for web traffic is to transport that data between the requester's machine and your target network/endpoint in a way that cannot be modified or snooped on by a third party. When using plain ol' port forwarding (not cloudflare tunnels) that burden of providing proof that the endpoint (your machine's IP) is the owner of example.com (and the encryption key) is on you. You use NPM/letsencrypt/acme to provide that proof and generate certs on your machine that the requester can inspect to verify that chain. When using cloudflare tunnels, cloudflare is now the owner of that burden of proof. They generate edge certs that the requester verifies for proof. The requester sends their traffic to a Cloudflare IP which then forwards the traffic to the associated cloudflared program which unencrypts it and then forwards it to where ever you configured it. You aren't necessary in that chain of burden. You've already "done that" by configuring CF with the tunnel/token/etc to get the traffic from their edge servers in the first place.
No. But this would still be the case even if you weren't using cloudflared. The whole point of a reverse proxy is that you have an application (nginx/npm) that handles all (encrypted) traffic in the "front" that then forwards that traffic to the correct location using rules. The forwarded traffic, as well as anything it receives back from the location before sending it back to the original requester is not encrypted. [1]
It's only as safe as the weakest point of your internal network. Generally, popular reverse proxy apps like nginx/traefik/caddy are battle-tested and mature software. There are so many eyes on these apps that bugs and vulnerabilities are usually discovered and fixed fast. nginx has been around for 20 years. It's unlikely an attack would be able to exploit the proxy app, specifically. Encrypted traffic on your network is only an issue if the network isn't secure to begin with. You're more likely to run into security issues with the individual containerized apps you are forwarding traffic to, since they may be less hardended. Finally, a note on NPM/nginx/traefik forwarding for a domain. You don't actually need to own the domain (or certs!) for these apps to still reverse proxy for them. nginx is perfectly happy to route traffic for example.com if the request header contains Host: example.com (or equivalent header). If you tried to do this with normal port forwarding using your own dns server you'd probably get big scary warnings in your browser about mismatched/missing certs, but nginx would still happily do it. This works for CF tunnels, though, because the response traffic first goes back through CF tunnel and to their edge server where the cert says it should be coming from. So everything is ok in that scenario. [1] Not encrypted unless you forward it as such! some apps can handle encryption themselves. They usually have instructions for setting up certs etc.. and explicitly tell you that you can use port 443 etc...in that case you could have NPM forward to the app as https traffic. You'd still need to set up certs individually on each app that supports this though. |
Beta Was this translation helpful? Give feedback.
I got a really complete answer by FoxxMD (FoxxMD on Github) which I'll forward here to help others in need :
I can't comment on anything specific about NPM since I don't use it but I can respond to a few points in your setup questions, generally, I think:
No. Encryption ends at the tunnel, before cloudflared (the tunnel application) forwards it to NPM
This is unnecessary. NPM does not need (or use) certs to handle the traffic coming from cloudflared. The traffic is unencrypted at this point. [2]
The po…