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
Support multiple hostnames in the allowfrom instead of a single one. #15
Is your feature request related to a problem? Please describe.
Since version 1.1.0, not only IP networks but also hostnames can be configured. So it is now possible to explicitly allow only one specific client to connect to the proxy, for example, -allowfrom=traefik
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.
Would it be possible to support multiple hostnames instead of a single one?
Describe the solution you'd like
Allow a comma-separated list in allowfrom, it is possible to do -allowfrom=traefik,dozzle,watchtower
Disclaimer
One solution would be to deploy a socket-proxy per instance, but with my little knowledge I have not be able to make this work.
thank You very much for Your contribution. I merged it into the develop branch and changed a detail about the DNS lookup. You can find a test image on docker hub: wollomatic/socket-proxy:testing
Thank you, tested with the following docker compose, seems to be working like a charm. :)
Details
# Inspired from https://github.com/wollomatic/traefik-hardened services:
# Step 1# Setup the Docker proxy.# This is to harden communications and avoid that if traefik is compromised the full host is compromised.dockerproxy:
image: wollomatic/socket-proxy:testingcontainer_name: private-docker-proxycommand:
# with this configuration socket-proxy acts similar to the tecnativa proxy.# For additional hardening please refer to the documentation of the wollomatic/socket-proxy image
- '-loglevel=info'# set to debug for far more logging
- '-allowfrom=reverse-proxy,dozzle'# - '-allowfrom=0.0.0.0/0'
- '-listenip=0.0.0.0'
- '-allowGET=/v1\..{1,2}/(version|containers/.*|events.*)'# this regexp allows readonly access only for requests that traefik needs
- '-shutdowngracetime=5'
- '-watchdoginterval=600'
- '-stoponwatchdog'restart: unless-stoppedread_only: truemem_limit: 64Mcap_drop:
- ALLsecurity_opt:
- no-new-privilegesuser: 65534:994# replace <<docker-gid>> (994) with the docker gid on your host system.# $ getent group docker# docker:x:994:volumes:
- /var/run/docker.sock:/var/run/docker.sock:ronetworks:
- docker-proxynet# Step 2# Setup Traefikreverse-proxy:
image: traefik:v3.0container_name: traefikread_only: trueports:
- 80:80# The HTTP port
- 443:443# The HTTPS port# The Web UI port (enabled by --api.insecure=true)# - 48080:8080depends_on:
- dockerproxysecurity_opt:
- no-new-privileges:true# user: 2000:2000 # user traefik has to be created on the host system# sudo useradd -u 2000 -M -s /usr/sbin/nologin traefiknetworks:
- docker-proxynet
- traefik-servicenetvolumes:
# So that traefik can listen to docker events# - "/var/run/docker.sock:/var/run/docker.sock:ro"
- ./letsencrypt:/letsencrypt
- ./logs/:/var/log/# Configuration
- ./traefik.yml:/etc/traefik/traefik.yml
- ./authusers.txt:/etc/traefik/authusers.txt:ro # userfile for basic authlabels:
- "traefik.enable=true"# expose traefik dashboard with TLS and basic auth# 1. create router
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.rule=Host(`traefik.${DOMAIN_NAME1}`)"
- "traefik.http.routers.traefik.service=api@internal"# - "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.tls.certresolver=myresolver"
- "traefik.http.routers.traefik.middlewares=traefik-auth"# 2. create basic auth middleware
- "traefik.http.middlewares.traefik-auth.basicauth.removeheader=true"
- "traefik.http.middlewares.traefik-auth.basicauth.usersfile=/etc/traefik/authusers.txt"# Step 3# Convert certificates from acme.json to proper usable format (pem).traefik-certs-dumper:
image: ldez/traefik-certs-dumper:v2.8.1depends_on:
- reverse-proxycontainer_name: traefik-certs-dumperentrypoint: sh -c 'apk add jq; while ! [ -e /data/acme.json ]|| ! [ `jq ".[] | .Certificates | length" /data/acme.json` != 0 ]; dosleep 1; done&& traefik-certs-dumper file --version v2 --watch--source /data/acme.json --dest /data/certs--post-hook "sh /hook.sh"'labels:
- "traefik.enable=false"volumes:
- ./letsencrypt:/data
- ./hook.sh:/hook.sh# Step 4dozzle:
image: amir20/dozzle:v5.4.2 # make sure you use the most recent versioncontainer_name: dozzleuser: 65534:65534read_only: truemem_limit: 256Mcap_drop:
- ALLsecurity_opt:
- no-new-privilegesdepends_on:
- dockerproxyenvironment:
DOZZLE_NO_ANALYTICS: trueDOZZLE_REMOTE_HOST: tcp://dockerproxy:2375networks:
- docker-proxynet
- traefik-servicenetlabels:
- "traefik.enable=true"
- "traefik.http.routers.dozzle.rule=Host(`dozzle.${DOMAIN_NAME1}`)"
- "traefik.http.routers.dozzle.entrypoints=websecure"
- "traefik.http.routers.dozzle.tls.certresolver=myresolver"
- "traefik.http.routers.dozzle.middlewares=dozzle-auth"
- "traefik.http.middlewares.dozzle-auth.basicauth.removeheader=true"
- "traefik.http.middlewares.dozzle-auth.basicauth.usersfile=/etc/traefik/authusers.txt"networks:
traefik-servicenet:
# external: true # this network has to be created once before starting:name: traefik-servicenet # docker network create traefik-servicenetdocker-proxynet:
driver: bridgeinternal: true
Activity
wollomatic commentedon May 5, 2024
Hi @ildyria,
thank You very much for Your contribution. I merged it into the develop branch and changed a detail about the DNS lookup. You can find a test image on docker hub: wollomatic/socket-proxy:testing
ildyria commentedon May 5, 2024
Thank you, tested with the following docker compose, seems to be working like a charm. :)
Details
wollomatic commentedon May 5, 2024
Hi @ildyria,
thanks for the feedback. I'll update the documentation, and then release version 1.3.0 tomorrow.
wollomatic commentedon May 6, 2024
Thanks again for the improvement. 1.3.0 ist now available on docker hub.