version: "3.8"
services:
  wg-easy:
    environment:
      # ⚠️ Required:
      # Change this to your host's public address
      - WG_HOST=knast.cc

      # Optional:
      - PASSWORD=Lukmignuind@1
      # - WG_PORT=51820
      # - WG_DEFAULT_ADDRESS=10.8.0.x
      # - WG_DEFAULT_DNS=1.1.1.1
      # - WG_MTU=1420
      # - WG_ALLOWED_IPS=192.168.15.0/24, 10.0.1.0/24
      # - WG_PRE_UP=echo "Pre Up" > /etc/wireguard/pre-up.txt
      # - WG_POST_UP=echo "Post Up" > /etc/wireguard/post-up.txt
      # - WG_PRE_DOWN=echo "Pre Down" > /etc/wireguard/pre-down.txt
      # - WG_POST_DOWN=echo "Post Down" > /etc/wireguard/post-down.txt
      
    image: weejewel/wg-easy
    container_name: wg-easy
    volumes:
      - /srv/wg-easy:/etc/wireguard
    ports:
      - "51820:51820/udp"
      - "51821:51821/tcp"
    networks:
      - traefik
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.wireguard.entrypoints=websecure"
      - "traefik.http.routers.wireguard.rule=Host(`wireguard.$DOMAIN_NAME`)"
      - "traefik.http.routers.wireguard.tls.certresolver=letsencr"
      - "traefik.http.services.wireguard.loadbalancer.server.port=51821"
      # - "traefik.http.routers.wireguard.middlewares=wireguard_auth"
      # - "traefik.http.middlewares.wireguard_auth.basicauth.users=admin:$$2a$$12$MkhjqyuriyoE5.Mhz14ZXOkfjE7wUEDb46e9argix38VHZ5aAuGQC"


networks:
  traefik:
    external: true


# # version: "2.1"
# # services:
# #   wireguard:
# #     image: ghcr.io/linuxserver/wireguard
# #     networks:
# #       - traefik
# #     container_name: wireguard
# #     cap_add:
# #       - NET_ADMIN
# #       - SYS_MODULE
# #     # environment:
# #       # - PUID=1000
# #       # - PGID=1000
# #       # - TZ=Europe/London
# #       # - SERVERURL=wireguard.knast.cc
# #       # - SERVERPORT=51820
# #       # - PEERS=1
# #       # - PEERDNS=auto
# #       # - INTERNAL_SUBNET=10.13.13.0
# #       # - ALLOWEDIPS=0.0.0.0/0
# #     volumes:
# #       - /srv/wireguard/config:/config
# #       - /lib/modules:/lib/modules
# #     ports:
# #       - 51820:51820/udp
# #     sysctls:
# #       - net.ipv4.conf.all.src_valid_mark=1
# #     restart: unless-stopped
# #     labels:
# #       - "traefik.enable=true"
# #       - "traefik.http.routers.wireguard.entrypoints=websecure"
# #       - "traefik.http.routers.wireguard.rule=Host(`wireguard.$DOMAIN_NAME`)"
# #       - "traefik.http.routers.wireguard.tls.certresolver=letsencr"

# # networks:
# #   traefik:
# #     external: true



# # version: "2.1"
# # services:
# #   wireguard:
# #     image: lscr.io/linuxserver/wireguard:latest
# #     container_name: wireguard
# #     cap_add:
# #       - NET_ADMIN
# #     environment:
# #       - PUID=1000
# #       - PGID=1000
# #       - TZ=Etc/UTC
# #       - SERVERURL=wireguard.domain.com #optional
# #       # - SERVERPORT=51820 #optional
# #       # - PEERS=1 #optional
# #       # - PEERDNS=auto #optional
# #       # - INTERNAL_SUBNET=10.13.13.0 #optional
# #       # - ALLOWEDIPS=0.0.0.0/0 #optional
# #       # - PERSISTENTKEEPALIVE_PEERS= #optional
# #       # - LOG_CONFS=true #optional
# #     volumes:
# #       - /path/to/appdata/config:/config
# #     ports:
# #       - 51820:51820/udp
# #     sysctls:
# #       - net.ipv4.conf.all.src_valid_mark=1
# #     restart: unless-stopped


# version: "3.7"

# ########################### NETWORKS
# networks:
#   t2_proxy:
#     external:
#       name: t2_proxy
#     ipam:
#       driver: default
#       config:
#       # - subnet: {Your Configured Subnet}
#   default:
#     driver: bridge

# ########################### SERVICES
# services:

#   wireguard:
#     image: linuxserver/wireguard
#     container_name: wireguard
#   # network_mode: service:traefik
#     networks:
#       t2_proxy:
#         ipv4_address: {Wireguard static IPv4 address}
#     cap_add:
#       - NET_ADMIN
#       - SYS_MODULE
#     environment:
#       - PUID={User ID}
#       - PGID={Group ID}
#       - TZ={Time Zone}
#       - SERVERURL={Server URL}
#       - SERVERPORT=51820
#       - PEERS=5
#       - PEERDNS={DNS Server for your connections}    
#       - INTERNAL_SUBNET={Subnet for your connections}
#     volumes:
#       - ./config:/config
#       - /usr/src:/usr/src
#       - /lib/modules:/lib/modules
#     sysctls:
#       - net.ipv4.conf.all.src_valid_mark=1
#     restart: unless-stopped
#     labels:
#       - "traefik.enable=true"
#       - "traefik.docker.network=t2_proxy"
#     ## UDP Routers
#       - "traefik.udp.routers.wireguard-udp.entrypoints=wireguard"
#     ## UDP Services
#       - "traefik.udp.routers.wireguard-udp.service=wireguard-udp-svc"
#       - "traefik.udp.services.wireguard-udp-svc.loadbalancer.server.port=51820"