You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature request] Per-container allowlists in unix socket mode #180
Describe the solution you'd like
I'd like to use docker labels to configure allowlists per container even in unix socket mode, in the way that Traefik or Crowdsec do. It'll allow to keep both the ease of configuration of docker labels and the increased security of not risking networking accidents.
Describe alternatives you've considered
Continue using networking mode or set up one socket-proxy per container.
Same wall here, and the code explains why this is unix-mode-incompatible rather than just undocumented. determineAllowList() in cmd/socket-proxy/handlehttprequest.go only performs the per-container lookup when cfg.ProxySocketEndpoint == "", and even inside that branch it keys the lookup off r.RemoteAddr: net.SplitHostPort then cfg.AllowLists.FindByIP(clientIPStr). A unix listener has no host:port to split, and the allowlist map is indexed by container IP throughout, including the refresh path, so on a socket there is no key to resolve. Worth noting the gate is on the upstream endpoint rather than on the listener, so a unix socket in either direction ends up on the default allowlist or a 403 rather than a container's list.
Three ways it could land, cheapest first:
Peer credentials. On Linux, syscall.GetsockoptUcred (stdlib, no new dependency) gives pid/uid/gid for an accepted unix connection, and with a shared PID namespace /proc/<pid>/cgroup names the container. Keeps today's label config exactly as it is, but it only works where shared namespaces and host-level access are acceptable.
One socket per container. At startup, for each container whose label declares an allowlist, create /run/socket-proxy/<name>.sock bound to that allowlist and keep the main socket on the default. Identity becomes the path, nothing has to be resolved per request, and the change is a startup label scan moved out of the network-mode branch plus a small listener map.
Name the allowlist in a header or query parameter. Cheapest and honestly weak: anything that can open the socket can claim another container's name, so it is an advisory label rather than a boundary.
Option 2 matches what you described most closely, since labels stay the config surface and one proxy still serves every container. If that direction is right, I am happy to prototype it: the label scan, the per-path listeners, and the docs section on unix mode.
Activity
mgkvibez commentedon Nov 18, 2026
Same wall here, and the code explains why this is unix-mode-incompatible rather than just undocumented.
determineAllowList()incmd/socket-proxy/handlehttprequest.goonly performs the per-container lookup whencfg.ProxySocketEndpoint == "", and even inside that branch it keys the lookup offr.RemoteAddr:net.SplitHostPortthencfg.AllowLists.FindByIP(clientIPStr). A unix listener has no host:port to split, and the allowlist map is indexed by container IP throughout, including the refresh path, so on a socket there is no key to resolve. Worth noting the gate is on the upstream endpoint rather than on the listener, so a unix socket in either direction ends up on the default allowlist or a 403 rather than a container's list.Three ways it could land, cheapest first:
Peer credentials. On Linux,
syscall.GetsockoptUcred(stdlib, no new dependency) gives pid/uid/gid for an accepted unix connection, and with a shared PID namespace/proc/<pid>/cgroupnames the container. Keeps today's label config exactly as it is, but it only works where shared namespaces and host-level access are acceptable.One socket per container. At startup, for each container whose label declares an allowlist, create
/run/socket-proxy/<name>.sockbound to that allowlist and keep the main socket on the default. Identity becomes the path, nothing has to be resolved per request, and the change is a startup label scan moved out of the network-mode branch plus a small listener map.Name the allowlist in a header or query parameter. Cheapest and honestly weak: anything that can open the socket can claim another container's name, so it is an advisory label rather than a boundary.
Option 2 matches what you described most closely, since labels stay the config surface and one proxy still serves every container. If that direction is right, I am happy to prototype it: the label scan, the per-path listeners, and the docs section on unix mode.