Skip to content

Instantly share code, notes, and snippets.

@juriansluiman
Last active February 26, 2023 17:35
Show Gist options
  • Save juriansluiman/d571d9b2710a19d0d77958dddd29f662 to your computer and use it in GitHub Desktop.
Save juriansluiman/d571d9b2710a19d0d77958dddd29f662 to your computer and use it in GitHub Desktop.
Traefik 2.2 with openvpn failover with udp+tcp protocol
version: '3'
networks:
web:
external: true
bridge:
external: true
services:
traefik:
image: traefik:v2.2
container_name: traefik
ports:
- "80:80"
- "443:443"
- "1194:1194/udp"
networks:
- web
- bridge
volumes:
- /var/www/traefik/traefik.toml:/etc/traefik/traefik.toml:rw
- /var/www/traefik/acme.json:/acme.json:rw
- /var/www/traefik/traefik.log:/traefik.log:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: always
openvpn-udp:
image: kylemanna/openvpn
container_name: ovpn-udp
cap_add:
- NET_ADMIN
depends_on:
- "traefik"
networks:
- web
command: ovpn_run --proto udp
labels:
- "traefik.udp.routers.openvpn.entrypoints=openvpn"
- "traefik.udp.routers.openvpn.service=openvpn"
- "traefik.udp.services.openvpn.loadbalancer.server.port=1194"
volumes:
- openvpn:/etc/openvpn
restart: always
openvpn-tcp:
image: kylemanna/openvpn
container_name: ovpn-tcp
cap_add:
- NET_ADMIN
depends_on:
- "traefik"
networks:
- web
command: ovpn_run --proto tcp
labels:
- "traefik.tcp.routers.openvpn.rule=HostSNI(`*`)"
- "traefik.tcp.routers.openvpn.entrypoints=websecure"
- "traefik.tcp.routers.openvpn.service=openvpn"
- "traefik.tcp.services.openvpn.loadbalancer.server.port=1194"
volumes:
- openvpn:/etc/openvpn
restart: always
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
[entryPoints.openvpn]
address = ":1194/udp"
@juriansluiman
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment