cross-posted from: https://programming.dev/post/39212874

I recently migrated my services from rootful docker to rootless podman quadlets. It went smoothly, since nothing I use actually needs to be rootful. Well, except for caddy. It needs to be able to attach to privileged ports 80 and 443.

My current way to bypass it is using HAProxy running as root and forwarding connections using proxy protocol. (Tried to use firewalld but that makes the client IP opaque to caddy.) But that adds an extra layer, which means extra latency. It’s perfectly usable, but I’d like to get rid of it, if possible.

I’m willing to run caddy in rootful podman if needed. But from what I understand, that means I can’t have it in the same rootless network as my other containers. I really don’t wanna open most of my containers’ ports, so that’s not an option.

So, I’m asking whether any of these three things are possible.

  1. Use firewalld to forward ports to caddy without obscuring the client’s IP.
  2. Make rootful caddy share a network with other rootless containers.
  3. Assign privileged ports to caddy somehow, in rootless mode. (I know there’s a way to make all these ports unprivileged, but is it possible to only assign these 2 ports as unprivileged?)

Or maybe there’s a fourth way that I’m missing. I feel like this is a common enough setup, that there must be a way to do it. Any pointers are appreciated, thanks.

  • @SinTan1729 How many user do you have on your machine, which could open and run a service on a privileged port?

    And when there is no application, which is providing a service on a privileged port, then there is no security issue from my point of view.

    And if you want to get absolutely secure, then you can restrict the access only to specific ports based on firewall rules.
    https://www.digitalocean.com/community/tutorials/ufw-essentials-common-firewall-rules-and-commands#how-to-allow-all-incoming-http-and-https

    • SinTan1729@programming.devOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 days ago

      Just a couple of friends use it. But I’d like to use this as a learning opportunity and do it the proper way. It seems that if I turn of masquerade in general, and use firewalld fine-grained rules to enable it when I actually need it, I might be able to achieve what I want. I’ll post an update to the original post if I can get it to work.

      • @SinTan1729 Thank you, now I can better understand why you want to avoid to open the privileged ports for non-root users which makes sense for your scenario.

        I’m in the easy situation, that I don’t have to think about such a scenario, because my selfhosting system is exclusive for me.

        • o/1MS\o ⌨️🐧 | #WeAreNatenom@norden.social
          link
          fedilink
          arrow-up
          0
          arrow-down
          1
          ·
          2 days ago

          I don’t know the exact agreement with your friends, but to avoid security issues I personally would use following way:
          - deny usage of all ports by firewall
          - allow only necessary ports by firewall
          - enable privileged ports by sysctl
          So it reduces additional layers and complexity.

          If one of your friends would provide a service on a specific port it has to be discussed with you.
          And if this is a privileged port, it is also possible.

          Or you can handle e.g. a web request with a rule in caddy.