Bookmark

Run OpenVPN Access Server in Docker

OpenVPN Access Server is a self-hosted VPN solution with a web administration interface. This version keeps the source ports, volume, and operation order while separating commands and adding practical safety notes.

Youtube video player

Install Docker on Linux

Log into Linux with a sudo-capable account and run the commands below. The source uses apt-key; on a current distribution, also check the official Docker installation documentation because this command is deprecated.

1
2
3
4
5
6
7
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
sudo apt install docker-ce docker-compose containerd.io -y
sudo systemctl enable docker && sudo systemctl start docker
sudo usermod -aG docker $USER
su - $USER

Run the OpenVPN Access Server container

Create the data directory and start the container. NET_ADMIN is required for VPN functions, so do not run this container on an uncontrolled host.

1
2
3
4
5
6
7
8
mkdir ~/docker/openvpn-as -p
docker run -d --name openvpn-as \
  --cap-add=NET_ADMIN \
  -p 943:943 \
  -p 8443:443 \
  -p 1194:1194/udp \
  -v ~/docker/openvpn-as:/openvpn \
  openvpn/openvpn-as

Read the temporary password generated by the container:

1
docker logs openvpn-as | grep 'Auto-generated pass'

Copy the value on the Auto-generated pass = line locally. Do not put the real password in Git or send it through chat.

Sign in and replace the password

  1. Open https://DNSorIP:943/admin. The initial certificate may be self-signed.
  2. Sign in as openvpn with the password from the log.
  3. Click Agree to accept the EULA.
  4. Choose User Management > User Permissions.
  5. Click the edit icon beside openvpn.
  6. Enter a new Password and click Save Settings.
  7. Click Logout, then sign in again with the new password.
  8. Check the container with docker ps and docker logs --tail=50 openvpn-as.

The ports are 943:943 for web access, 8443:443 for HTTPS, and 1194:1194/udp for VPN. Expose them through firewall/NAT rules only when required.

Sources and video


0 Bình luận

Góp Ý / Bình Luận / Đánh giá