VPN

For the VPN service, I use a glutun container to connect other containers to the VPN.

Documentation for gluetun can be found here.

In order for this to work properly, the ports from the containers using the VPN must be moved to the glutun config. The following option is added to the apps config file:

network_mode: "container:gluetun"

This will place the app container on the same docker network as the glutun container, and then all outbound traffic from the container will be sent out through the VPN.

The gluetun container compose file looks like this to start with:

services:
 gluetun:
    image: qmcgaw/gluetun
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    ports:
      - 8888:8888/tcp
      - 8388:8388
    volumes:
      - /var/lib/gluetun:/gluetun
    environment:
      - VPN_SERVICE_PROVIDER=mullvad
      - VPN_TYPE=wireguard
      - WIREGUARD_PRIVATE_KEY=provided by mullvad
      - WIREGUARD_ADDRESSES=provided by mullvad
      - SERVER_COUNTRIES=USA
      - TZ=America/New_York
      - UPDATER_PERIOD=24h
      - UNBLOCK=usenetserver.com
      - FIREWALL_OUTBOUND_SUBNETS=192.168.0.0/24
    devices:
      - /dev/net/tun:/dev/net/tun
    restart: unless-stopped
networks: {}

The UNBLOCK=usenetserver.com is used to make sure that traffic from usenet is not blocked.