Sign inSign up

hbixu/openvpn-proxy

By hbixu

Updated 8 months ago

Docker image that establishes a VPN connection through OpenVPN and provides a SOCKS5 proxy.

Image
Networking
0

1.1K

hbixu/openvpn-proxy repository overview

OpenVPN Proxy

Docker container that establishes a VPN connection through OpenVPN and provides a SOCKS5 proxy that only works when the VPN is active. SOCKS5 supports any type of traffic (TCP/UDP), making it more versatile than HTTP proxies.

Features

  • ✅ Establishes VPN connection through OpenVPN
  • SOCKS5 Proxy (go-socks5-proxy) that routes traffic through VPN - supports any type of traffic (TCP/UDP)
  • Uses OpenVPN --up and --down scripts to manage proxy automatically
  • ✅ Automatic VPN monitoring
  • ✅ Automatic VPN restart on failure
  • ✅ Proxy automatically disabled when VPN drops
  • ✅ Based on LinuxServer.io baseimage-alpine

Requirements

  • Docker and Docker Compose installed
  • OpenVPN configuration file (.ovpn)
  • Root access or permissions to use NET_ADMIN and /dev/net/tun

Supported Architectures

The architectures supported by this image are:

ArchitectureAvailable
arm64
amd64

Version History

ReleaseImageOpenVPNgo-socks5-proxy
1.0.03.23-d34fa4d2-ls42.6.16-r01.0.0

Environment variables

VariableRequiredDescriptionDefault
OPENVPN_CONFIGYesOpenVPN filename (must be in /config/openvpn/)-
TZ❌ NoTimezoneEurope/Lisbon
PUID❌ NoUser ID1000
PGID❌ NoGroup ID1000
LOG_ROTATE_DAYS❌ NoNumber of days to keep rotated logs7
VPN_ENABLED❌ NoEnable/disable VPN (set to false to test proxy without VPN)true
PROXY_PORT❌ NoSOCKS5 proxy port1080
PROXY_ALLOWED_NETWORKS❌ NoAllowed networks (space separated)10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
VPN_CHECK_INTERVAL❌ NoVPN check interval (seconds)5
VPN_CHECK_HOST❌ NoHost to check VPN connectivity8.8.8.8

Docker compose example

services:
  openvpn-proxy:
    image: hbixu/openvpn-proxy:latest
    container_name: openvpn-proxy
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    devices:
      - /dev/net/tun
    volumes:
      - ./openvpn-configs:/config/openvpn:ro
      - ./logs:/var/log
    environment:
      # OpenVPN configuration filename (must be in ./openvpn-configs/)
      - OPENVPN_CONFIG=config.ovpn
      # Timezone (default: Europe/Lisbon, defined in Dockerfile)
      - TZ=Europe/Lisbon
      # User ID and Group ID (default: 1000, defined in Dockerfile)
      - PUID=1000
      - PGID=1000
      # Log rotation: number of days to keep logs
      - LOG_ROTATE_DAYS=7
      # Enable/disable VPN (set to "false" to test proxy without VPN)
      # When false: proxy starts immediately without VPN connection
      - VPN_ENABLED=true
      # Optional: Override defaults from Dockerfile (uncomment if needed)
      # - PROXY_PORT=1080                    # Default: 1080
      # - PROXY_ALLOWED_NETWORKS=10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
      # - VPN_CHECK_INTERVAL=5               # Default: 5 seconds
      # - VPN_CHECK_HOST=8.8.8.8            # Default: 8.8.8.8
    ports:
      - "1080:1080"  # Host port 1080 -> Container port 1080
    restart: unless-stopped
    # Healthcheck - verifies if OpenVPN and proxy are working
    healthcheck:
      test: ["CMD", "/root/healthcheck.sh"]
      interval: 30s
      timeout: 10s
      start_period: 60s
      retries: 3
    # DNS configuration
    # Para usar AdGuard Home no router, adicione o IP do router como primeiro DNS
    # Exemplo: dns: [ "192.168.1.1", "8.8.8.8", "1.1.1.1" ]
    # Para descobrir o IP do router: ip route | grep default
    dns:
      - 8.8.8.8      # Google DNS
      - 8.8.4.4      # Google DNS (backup)
      - 1.1.1.1      # Cloudflare DNS (backup)
    networks:
      - vpn-network

networks:
  vpn-network:
    driver: bridge

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007.

Tag summary

Content type

Image

Digest

sha256:ae5b7243e

Size

15.1 MB

Last updated

8 months ago

docker pull hbixu/openvpn-proxy