I hade a problem running Pangolin on my server at the house , not sure why…but I did want that kind of setup so i spined this up and it seem to work fine. What do you think about this setup?
compose file:
services:
WireGuard VPN Gateway
gluetun:
image: qmcgaw/gluetun
container_name: gluetun
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
restart: unless-stopped
volumes:
- ./gluetun/wireguard:/gluetun
environment:
- VPN_SERVICE_PROVIDER=custom
- VPN_TYPE=wireguard
- WIREGUARD_PRIVATE_KEY=OF3BKQ6N7xxxxxxxx=
- WIREGUARD_ADDRESSES=10.8.0.6/24 # Changed back to /24
- WIREGUARD_ENDPOINT_IP=108.xx.xx.xx
- WIREGUARD_ENDPOINT_PORT=51820
- WIREGUARD_PUBLIC_KEY=2m8S/MDXRZ5xxxxxxxx=
- DNS_ADDRESS=8.8.8.8,8.8.4.4 # Changed to Google DNS
- BLOCK_MALICIOUS=off # Disable malicious IP blocking
- DOT=off # Disable DNS over TLS
ports:
- “8080:8080” # Gluetun admin interface (optional)
labels:
- “traefik.enable=false”
networks:
- proxy
Main Traefik (NO VPN - routes to all services)
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
ports:
- “80:80”
- “443:443”
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik/traefik.yml:/etc/traefik/traefik.yml:ro
- ./traefik/config:/etc/traefik/config:ro
- ./traefik/acme:/etc/traefik/acme:rw
- ./traefik/logs:/var/log/traefik
environment:
- DUCKDNS_TOKEN=62f00a92-3f47-4275-xxxxxxxx
labels:
- “traefik.enable=true”
- “traefik.http.routers.traefik.entrypoints=web”
- “traefik.http.routers.traefik.rule=Host(traefik.xxxxxx.duckdns.org
)”
- “traefik.http.middlewares.traefik-auth.basicauth.users=admin:$$2y$$xxxxxxxxxxxxxx”
- “traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https”
- “traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=websecure”
- “traefik.http.routers.traefik.middlewares=traefik-https-redirect”
- “traefik.http.routers.traefik-secure.entrypoints=websecure”
- “traefik.http.routers.traefik-secure.rule=Host(traefik.xxxxxxx.duckdns.org
)”
- “traefik.http.routers.traefik-secure.middlewares=traefik-auth”
- “traefik.http.routers.traefik-secure.tls=true”
- “traefik.http.routers.traefik-secure.tls.certresolver=letsencrypt”
- “traefik.http.routers.traefik-secure.tls.domains[0].main=xxxxxx.duckdns.org”
- “traefik.http.routers.traefik-secure.tls.domains[0].sans=*.xxxxx.duckdns.org”
- “traefik.http.routers.traefik-secure.service=api@internal”
networks:
- proxy
Example: Service WITHOUT VPN (normal routing)
#whoami-normal:
#image: traefik/whoami
#container_name: whoami-normal
#restart: unless-stopped
#labels:
#- “traefik.enable=true”
#- “traefik.http.routers.whoami-normal.rule=Host(whoami-normal.xxxxx.duckdns.org
)”
#- “traefik.http.routers.whoami-normal.entrypoints=websecure”
#- “traefik.http.routers.whoami-normal.tls.certresolver=letsencrypt”
#networks:
#- proxy
Example: Service WITH VPN (routed through Gluetun)
whoami-vpn:
image: traefik/whoami
container_name: whoami-vpn
restart: unless-stopped
network_mode: “service:gluetun” # This routes through VPN
depends_on:
- gluetun
labels:
- “traefik.enable=true”
- “traefik.http.routers.whoami-vpn.rule=Host(whoami-vpn.xxxxx.duckdns.org
)”
- “traefik.http.routers.whoami-vpn.entrypoints=websecure”
- “traefik.http.routers.whoami-vpn.tls.certresolver=letsencrypt”
# Note: VPN services need to be discovered by container name since they share Gluetun’s network
- “traefik.http.services.whoami-vpn.loadbalancer.server.port=80”
Portainer - VPN:
portainer:
image: portainer/portainer-ce
container_name: portainer
restart: unless-stopped
network_mode: “service:gluetun”
depends_on:
- gluetun
security_opt:
- no-new-privileges:true
#networks:
#- proxy
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./portainer/data:/data
labels:
- “traefik.enable=true”
- “traefik.http.routers.portainer.entrypoints=web”
- “traefik.http.routers.portainer.rule=Host(portainer.xxxxx.duckdns.org
)”
- “traefik.http.middlewares.portainer-https-redirect.redirectscheme.scheme=https”
- “traefik.http.routers.portainer.middlewares=portainer-https-redirect”
- “traefik.http.routers.portainer-secure.entrypoints=websecure”
- “traefik.http.routers.portainer-secure.rule=Host(portainer.xxxxx.duckdns.org
)”
- “traefik.http.routers.portainer-secure.tls=true”
- “traefik.http.routers.portainer-secure.service=portainer”
- “traefik.http.services.portainer.loadbalancer.server.port=9000”
networks:
name: proxy
external: true
And using this tag with existing containers.
network_mode: “container:gluetun”