Replies: 3 comments 2 replies
-
No we recommend using proper systemd user services that are part of the user session. Using User= will not create the proper systemd user sessions and runs in a different environment. |
Beta Was this translation helpful? Give feedback.
-
I tried out running caddy as systemd system service (with systemd directive graph TB
a1[curl] -.->a2[caddy container reverse proxy]
a2 -->|"for http://whoami.example.com:80"| a3["whoami container"]
Files/etc/systemd/system/caddy.service
/etc/systemd/system/caddy.socket
/home/caddytest1/.config/containers/systemd/whoami.container
/home/caddytest1/.config/containers/systemd/mynet.network
/home/caddytest1/Caddyfile
Test it outFirst enable linger for the user caddytest1 Then start the systemd system socket unit caddy.socket Then download the URL http://whoami.example.com:80 from the caddy container and see that the request is proxied to the container whoami.example.com. Resolve whoami.example.com to 127.0.0.1.
The following output is printed
result: The request was proxied by caddy to whoami. It worked. I also tried About the system:
Side noteI'll probably add this as an example (with status experimental) to |
Beta Was this translation helpful? Give feedback.
-
Ok thanks for all the reply. @Luap99 : I did not want to use the systemd user services because they don't allow me to bind on a port < 1024 by default |
Beta Was this translation helpful? Give feedback.
-
Issue Description
Hi everyone!
I'm trying to setup a systemd.socket service listening on a privileged port (80) that will trigger a podman container serving this port.
I'd like the podman container to be run as a standard user.
However specifying the
User
in the[Service]
key of the.container
file does not work for systemd.I'll show first two files that do exactly what I want (except the service is run directly and not in podman):
and
(If you want to try this you likely need to change the
User
and the paths to the binary / config files)(Also for this use case, we need Caddy in version >= 2.9.0-beta3 otherwise there is no support of binding to a file descriptor)
The Caddyfile (It is the same for all the tests in this issue):
You can perform a request by doing
curl http://localhost:80 -H 'Host: example.com'
If you run
ps aux | grep caddy
you'll see that the caddy binary is not ran by root.What I'm trying to achieve now is to do the same thing for the socket but for the service, use a
.container
file (located in/etc/containers/systemd/caddy.container
) to trigger a podman run of caddy and still being rootless.Here are the files I'm using for this:
And now when I'm doing
curl http://localhost:81 -H 'Host: example.com'
I have a permission issue in thecaddy.service
logs that basically says that caddy is running as themanu
inside the container and thus it can't create some files.So my questions are:
P.S: i'm aware of different ways of lowering privileges for binding on 80 (capabilities, changing the lowest port number for unprivileged users, ..) but I'd like not to use those.
Steps to reproduce the issue
See the description at the beginning
Describe the results you received
See the description at the beginning
Describe the results you expected
See the description at the beginning
podman info output
I'm running podman 4.9.3 on Ubuntu 24.04 LTS
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
Additional environment details
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting
Beta Was this translation helpful? Give feedback.
All reactions