百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

socket-proxy

> DevOps
开源

安全设计的灵活 Unix 套接字代理。内置零依赖的内存安全 Go 语言,在容器中不需要 shell 或解释器。这是一个现代的替代方案。

400 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

安全设计的灵活 Unix 套接字代理。内置零依赖的内存安全 Go 语言,在容器中不需要 shell 或解释器。这是一个现代的替代方案。

socket-proxy

Latest image

  • wollomatic/socket-proxy:1.13.1 / ghcr.io/wollomatic/socket-proxy:1.13.1
  • wollomatic/socket-proxy:1 / ghcr.io/wollomatic/socket-proxy:1

[!IMPORTANT]

Usage with Traefik >= 2.11.31 / >= 3.6.1

Due to a change in how Traefik retrieves the Docker API version (traefik/traefik#12256), the Socket-Proxy configuration for Traefik must be updated to allow HEAD requests to /_ping:

 - '-allowHEAD=/_ping'

Otherwise, Traefik would fall back to API version 1.51, which would break the Docker provider on older Docker versions.

About

socket-proxy is a lightweight, secure-by-default unix socket proxy. Although it was created to proxy the docker socket to Traefik, it can also be used for other purposes. It is heavily inspired by tecnativa/docker-socket-proxy.

As an additional benefit, socket-proxy can be used to examine the API calls of the client application.

The advantage over other solutions is the very slim container image (from-scratch-image) without any external dependencies (no OS, no packages, just the Go standard library). It is designed with security in mind, so there are secure defaults and an additional security layer (IP address-based access control) compared to most other solutions.

The allowlist is configured for each HTTP method separately using the Go regexp syntax, allowing fine-grained control over the allowed HTTP methods. In bridge network mode, each container that uses socket-proxy can be configured with its own allowlist.

The source code is available on GitHub: wollomatic/socket-proxy

Getting Started

Some examples can be found in the wiki and in the examples directory of the repo.

Warning

You should know what you are doing. Never expose socket-proxy to a public network. It is meant to be used in a secure environment only.

Installing

The container image is available on Docker Hub (wollomatic/socket-proxy) and on the GitHub Container Registry (ghcr.io/wollomatic/socket-proxy).

To pin one specific version, use the version tag (for example, wollomatic/socket-proxy:1.13.0 or ghcr.io/wollomatic/socket-proxy:1.13.0). To always use the most recent version, use the 1 tag (wollomatic/socket-proxy:1 or ghcr.io/wollomatic/socket-proxy:1). This tag will be valid as long as there is no breaking change in the deployment.

There may be an additional docker image with the testing-tag. This image is only for testing. Likely, documentation for the testing image could only be found in the GitHub commit messages. It is not recommended to use the testing image in production.

Every socket-proxy release image is signed with Cosign. The public key is available on GitHub: wollomatic/socket-proxy/main/cosign.pub and https://wollomatic.de/socket-proxy/cosign.pub. For more information, please refer to the Security Policy. As of version 1.6, all multi-arch images are signed.

Migrating from other Docker socket proxies

[!TIP] If you are coming from tecnativa/docker-socket-proxy or linuxserver/docker-socket-proxy, configuring a regular expression allowlist may seem more complex at first.

To simplify migration, you can use the Socket Proxy Configuration Converter. The tool runs entirely in your browser and converts existing docker-socket-proxy environment variable configurations into equivalent regular expression allowlists for wollomatic/socket-proxy.

The converter is fully open source. Its source code is available at wollomatic/socket-proxy-configurator.

Allowing access

Because of the secure-by-default design, you need to allow every access explicitly.

This is meant to be an additional layer of security. It does not replace other security measures, such as firewalls, network segmentation, etc. Do not expose socket-proxy to a public network.

Setting up the TCP listener

Socket-proxy listens per default only on 127.0.0.1. Depending on what you need, you may want to set another listener address with the -listenip parameter. In almost every use case, -listenip=0.0.0.0 will be the correct configuration when using socket-proxy in a docker image.

Using a unix socket instead of a TCP listener

If you want to proxy/filter the unix socket to a new unix socket instead to a TCP listener, you need to set the -proxysocketendpoint parameter or the SP_PROXYSOCKETENDPOINT env variable to the socket path of the new unix socket. This will also disable the TCP listener.

For example -proxysocketendpoint=/tmp/filtered-socket.sock

[!NOTE] Versions prior to 1.10.0 of socket-proxy set the default file permissions of the Unix socket to 0400, instead of 0600 as stated in the documentation.

Setting up the IP address or hostname allowlist

Per default, only 127.0.0.1/32 is allowed to connect to socket-proxy. You may want to set another allowlist with the -allowfrom parameter, depending on your needs.

Alternatively, not only IP networks but also hostnames can be configured. So it is now possible to explicitly allow one or more specific hostnames to connect to the proxy, for example, -allowfrom=traefik, or -allowfrom=traefik,dozzle.

Using the hostname is an easy-to-configure way to have more security. Access to the socket proxy will not even be permitted from the host system.

Setting up the allowlist for requests

You must set up regular expressions for each HTTP method the client application needs access to.

The name of a parameter should be "-allow", followed by the HTTP method name (for example, -allowGET). The request will be allowed if that parameter is set and the incoming request matches the method and path matching the regexp. If unset, the corresponding HTTP method is disallowed.

It is also possible to configure the allowlist via environment variables. The variables are called "SP_ALLOW_", followed by the HTTP method (for example, SP_ALLOW_GET).

If both command-line parameter and environment variable are configured for a particular HTTP method, the environment variable is ignored.

Use Go's regexp syntax to create the patterns for these parameters. To avoid insecure configurations, ^ and $ are added automatically to the start and end of the pattern. Note: invalid regexp results in program termination.

Examples (command-line):

  • '-allowGET=/v1\..{1,2}/(version|containers/.*|events.*)' could be used for allowing access to the docker socket for Traefik v2.
  • '-allowHEAD=.*' allows all HEAD requests.
  • '-allowGET=/version -allowGET=/_ping' supports using -allowGET multiple times

Examples (env variables):

  • 'SP_ALLOW_GET="/v1\..{1,2}/(version|containers/.*|events.*)"' could be used for allowing access to the docker socket for Traefik v2.
  • 'SP_ALLOW_HEAD=".*"' allows all HEAD requests.
  • 'SP_ALLOW_GET="/version" SP_ALLOW_GET_2="/_ping"' supports multiple SP_ALLOW_GET entries

For more information, refer to the Go regexp documentation.

An excellent online regexp tester is regex101.com.

To determine which HTTP requests your client application uses, you could switch socket-proxy to debug log level and look at the log output while allowing all requests in a secure environment.

[!NOTE] Starting with version 1.12.0, the socket-proxy supports using multiple -allow* entries in params, environment, or docker labels.

Setting up bind mount restrictions

By default, socket-proxy does not restrict bind mounts. If you want to add an additional layer of security by restricting which directories can be used as bind mount sources, you can use the -allowbindmountfrom parameter or the SP_ALLOWBINDMOUNTFROM environment variable.

When configured, socket-proxy inspects supported Docker API requests and only allows direct host bind sources from the specified directories or their subdirectories. Each directory must start with /. Multiple directories can be specified separated by commas.

For example:

  • -allowbindmountfrom=/home,/var/log allows bind mounts from /home, /var/log, and any subdirectories like /home/user/data or /var/log/app
  • SP_ALLOWBINDMOUNTFROM="/app/data,/tmp" allows bind mounts from /app/data and /tmp directories

Bind mount restrictions are applied to versioned and unversioned container, Swarm service, and volume-create endpoints. They cover legacy bind syntax (-v /host/path:/container/path), modern bind mounts, and local volume-driver options that use o=bind or o=rbind. VolumesFrom is rejected while this restriction is active because the referenced container's mount sources are not present in the request being checked. Other volume types, including ordinary named volumes, NFS, CIFS, block-device volumes, and custom volume drivers, are not treated as host bind mounts.

[!WARNING] This option is a request filter, not a sandbox for otherwise untrusted Docker API clients. It cannot resolve host-side symbolic links, inspect a named volume that was created outside the filtered /volumes/create endpoint, or determine what a custom volume plugin exposes. It also does not restrict other host-access mechanisms such as privileged containers, host namespaces, added capabilities, or device mappings. Do not grant container- or service-creation endpoints to clients that must not control the Docker host; use the HTTP method/path allowlists, network isolation, and Docker authorization controls as additional boundaries.

Setting up per-container allowlists

Allowlists for both requests and bind mount restrictions can be specified for particular containers. To do this:

  1. Set -proxycontainername or the environment variable SP_PROXYCONTAINERNAME to the name of the socket proxy container.
  2. Make sure that each container that will use the socket proxy is in a Docker network that the socket proxy container is also in.
  3. Use the same regex syntax for request allowlists and for bind mount restrictions that were discussed earlier, but for labels on each container that will use the socket proxy. Each label name has the prefix .allow.; by default this is socket-proxy.allow., with socket-proxy.allow.bindmountfrom for bind mount restrictions. Set -dockerlabelprefix or SP_DOCKERLABELPREFIX when multiple socket proxies share a Docker daemon. For example, -dockerlabelprefix=traefik-socket-proxy uses labels beginning with traefik-socket-proxy.allow..
yaml
services:
  traefik:
    # [...] see github.com/wollomatic/traefik-hardened for a full example
    networks:
      - traefik-servicenet # this is the common traefik network
      - docker-proxynet    # this should be only restricted to traefik and socket-proxy
    labels:
      - 'socket-proxy.allow.get=.*' # allow all GET requests to socket-proxy
      - 'socket-proxy.allow.head=/version' # HEAD `/version` requests to socket-proxy
      - 'socket-proxy.allow.head.1=/exec' # another HEAD `exec` requests to socket-proxy

When this is used, it is not necessary to specify the container in -allowfrom as the presence of the allowlist labels will grant corresponding access.

Container health check

Health checks are disabled by default. As the socket-proxy container may not be exposed to a public network, a separate health check binary is included in the container image. To activate the health check, the -allowhealthcheck parameter or the environment variable `SP_ALLOWHEAL

Issues· 18 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gocontainerdockerdocker-socketdocker-socket-proxy

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类DevOps
定价开源

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理