安裝 openvpn-ui (OpenVPN + 簡易 WebUI) 方案

  1. 建立目錄與下載相關檔案

    mkdir openvpn-ui
    cd openvpn-ui
    mkdir -p ./config
    wget https://raw.githubusercontent.com/d3vilh/openvpn-server/refs/heads/main/server.conf -O server.conf
    wget https://raw.githubusercontent.com/d3vilh/openvpn-server/refs/heads/main/config/easy-rsa.vars -O config/easy-rsa.vars
    wget https://raw.githubusercontent.com/d3vilh/openvpn-server/refs/heads/main/config/client.conf -O config/client.conf
    wget https://github.com/tryweb/docker-compose/raw/refs/heads/main/openvpn-ui/fw-rules.sh -O fw-rules.sh
    wget https://github.com/tryweb/docker-compose/raw/refs/heads/main/openvpn-ui/.env.example -O .env
    wget https://github.com/tryweb/docker-compose/raw/refs/heads/main/openvpn-ui/docker-compose.yml -O docker-compose.yml
    chmod a+x fw-rules.sh

  2. 編輯 .env 設定管理者帳號密碼

    vi .env

    https://github.com/tryweb/docker-compose/raw/refs/heads/main/openvpn-ui/.env.example
    ADMIN_USERNAME=admin
    ADMIN_PASSWORD=eyJhIjoixxxxxxxxxxxxxx

    https://github.com/tryweb/docker-compose/raw/refs/heads/main/openvpn-ui/.env.example

  3. 啟動服務

    docker compose up -d

  • 設定 server
    • 修改 Port → 443, Proto → TCP
    • Push Route (Your Home subnet), Push Redirect-gateway (#註記掉避免所有流量都往 vpn 走), Custom Option Three (增加需要走 vpn 的網段路由)
  • 設定 client
    • 修改 Connection Address (改成實際對外 Domain Name 或 IP), Connection Port → 443, Proto → tcp
    • Redirect Gateway (#註記掉避免所有流量都往 vpn 走)
  • 設定憑證預設資料
    • 修改 EASYRSA_REQ_COUNTRY → TW, EASYRSA_REQ_PROVINCE → TW, EASYRSA_REQ_CITY→ Taipei
    • EASYRSA_REQ_ORG (自己的公司), EASYRSA_REQ_EMAIL (自己的Email), EASYRSA_REQ_OU (自己的部門)
  • 重啟容器讓設定生效
  • tech/openvpn-ui.txt
  • 上一次變更: 2026/01/13 14:11
  • jonathan