Comment on Question on SSL traffic between podman containers and clients (should I run k3s?)
vegetaaaaaaa@lemmy.world 1 year ago
I’m missing the point about a reverse-proxy being an SSL termination endpoint
Yes, that’s usually on of the jobs of the reverse proxy. Communication between the RP and an application container running on the same host is typically unencrypted. If you’re really paranoid about a rogue process intercepting HTTP connections between 2 other processes, setup separate container networks for each application, and/or use unix sockets.
ChatGPT suggested I use Kubernetes
wtf…
MigratingtoLemmy@lemmy.world 1 year ago
Hey, thanks for your comment. Could you explain a bit more about how using Unix sockets would improve my security posture here (in terms of not having unencrypted traffic on the network)? I will think about creating separate namespaces in podman.
Good thing I asked haha. Is the fact that I mentioned ChatGPT setting a wrong impression? I like to go and ask about such questions to ChatGPT/Bing, sometimes they give wonderful answers, sometimes, not the best. Like this one. I thought that there must be an easier way to secure my traffic/do as much as possible to restricting it without jumping straight to k3s.
Thanks!
Chewy7324@discuss.tchncs.de 1 year ago
Nothing wrong with asking LLM’s about topics, I’d even say it’s a good idea instead of directly asking on a forum. Just like searching before asking, asking an LLM before asking humans is good.
And mentioning where you got the recommendation for k8s is also helpful. I’m not knowledgeable about k8s, but I guess the “wtf” was about the overkill of recommending k8s when simpler solutions exist.
Unix sockets have permissions like any file, so it’s simple to restrict access to a user/group and thus process running as the user. If it’s unencrypted http on a server other processes could listen on localhost, but I’m unsure about that part.
MigratingtoLemmy@lemmy.world 1 year ago
Sorry for replying this late; I wanted to read more about Unix sockets and podman before I got back. Thanks for your comment.
I already responded to the other commenter with what I’ve understood and my plans, I’ll paste it here too:
If I understand correctly, Unix sockets specifically allow two or more processes to communicate amongst each other, and are supporter on Podman (and Docker).
Now, the question is: how do I programmatically programmatically utilise sockets for containers to communicate amongst each other?
I was considering a reverse proxy per pod as someone else suggested, since every podman pod has its own network namespace. Connecting between pods should likely be through the reverse proxies then. I just need to figure out how I can automate the deployment of such proxies along with the pods.
Thanks again for your comment, and please let me know if I’m missing anything.
Chewy7324@discuss.tchncs.de 1 year ago
Thanks for the long reply. Sadly I don’t know enough about unix sockets and docker/podman networking to help you.
I’ve only used unix sockets with postgresql and signald. For both I had to mount the socket into the container and for the postgres I had to change the config to use unix sockets.
vegetaaaaaaa@lemmy.world 1 year ago
Not at all, but the fact that it suggested jumping straight to k8s for such a trivial problem is… interesting.
Unix sockets enforce another layer of protection by requiring the user/application writing/reading to/from them to have a valid UID or be part of the correct group (traditional Linux/Unix permission system). Whereas using plain localhost HTTP networking, a rogue application could somehow listen on the loopback interface and/or exploit a race condition to bind the port and prentend to be the “real” application. Network namespaces (which container management tools use to create isolated virtual networks) mostly solve this problem. Again, basic unencrypted localhost networking is fine for a vast majority of use cases/threat models.
MigratingtoLemmy@lemmy.world 1 year ago
Hey, thanks for your comment. My apologies in replying this late; I wanted to read more about Unix sockets and podman before I got back.
If I understand correctly, Unix sockets specifically allow two or more processes to communicate amongst each other, and are supporter on Podman (and Docker).
Now, the question is: how do I programmatically programmatically utilise sockets for containers to communicate amongst each other?
I was considering a reverse proxy per pod as someone else suggested, since every podman pod has its own network namespace. Connecting between pods should likely be through the reverse proxies then. I just need to figure out how I can automate the deployment of such proxies along with the pods.
Thanks again for your comment, and please let me know if I’m missing anything.
vegetaaaaaaa@lemmy.world 1 year ago
Sockets are filesystem objects, similar to a file. So for 2 containers to access the same socket, the container exposing the socket must export it to the host filesystem via a
bind
mount/volume, and the container that needs read/write on this socket must be able to access it, also via a bind mount. The user ID or groups of the user accessing the socket must be allowed to access the socket via traditional unix permissions.Again, I personally do not bother with this, install the reverse proxy directly on the host, and configure it to forward traffic over HTTP on the loopback interface to your containers.
That’s a separate question. I use ansible for all deployment/automation needs - when it comes to podman I use the podman_container and podman_generate_systemd modules to automate deployment of containers as systemd services. The ansible also configures my reverse proxy to forward traffic to the container (simply copy files in
/etc/apache2/sites-available/…; a2enconf; systemctl reload apache2
). I have not used pods yet, but there is a podman_pod module. A simple bash script should also do the trick in a first time.