VpnHood!

Run VpnHood! SERVER in Docker

Run the server as a container on any Linux machine with Docker. One command installs it, as a managed server or a standalone one, and the container keeps the server running and up to date.

Before you start

  • A Linux machine with a public IP address, on x64 or arm64. The image is built for both.
  • Root access.
  • Docker with its compose plugin. The installer can install it for you on Ubuntu, Debian and the distributions based on them.
  • TCP port 443 open, both in the machine's firewall and in your hosting provider's. The container shares the host's network, so the server listens on the host's port directly.

Install a managed server

In VpnHood! MANAGER, open Servers, select Add, name the server and select Create. Among the ways to install it, choose Install on Linux manually by running a command. In the command MANAGER shows, change VpnHoodServer-linux.sh to VpnHoodServer.docker.sh, then run it on the machine. It installs the container with the settings that connect the server to MANAGER, and asks the question the standalone install below asks.

For a container you created already, choose Install Manually by configuring appsettings instead. Save the settings MANAGER shows as /opt/VpnHoodServer/storage/appsettings.json on the host, then restart the container with sudo docker restart VpnHoodServer.

Then create the access keys for your devices in MANAGER, under Access Tokens.

Install a standalone server

Run this command. It downloads the compose file, starts the server's container and asks you one question.

sudo su -c "bash <( wget -qO- https://github.com/vpnhood/VpnHood.App.Server/releases/latest/download/VpnHoodServer.docker.sh)"

When it asks Install Docker (y/n)?, type y to have Docker installed, or n if the machine has it already.

In a script, install without the question. Leave out -install-docker if Docker is installed already.

sudo su -c "bash <( wget -qO- https://github.com/vpnhood/VpnHood.App.Server/releases/latest/download/VpnHoodServer.docker.sh) -install-docker -q"

The server keeps its settings, keys and logs in /opt/VpnHoodServer/storage on the host, so they outlive the container.

Create an access key

Run this on the machine. The key is made inside the server's container, so it uses the server's own settings.

sudo docker exec VpnHoodServer /app/vhsupervisor gen

For example, a key for one phone

sudo docker exec VpnHoodServer /app/vhsupervisor gen -name Phone -maxClient 1

The output and the options are the same as for a standalone server installed without Docker: copy the line under --- AccessKey ---, and see Create your first access key for the options that limit a key.

Connect

Install VpnHood! CLIENT on each device, add the key, and connect.

Start, stop and check the server

The container is called VpnHoodServer. Docker starts it again when the machine restarts, and inside it the server is started again if it crashes.

sudo docker logs VpnHoodServer
sudo docker stop VpnHoodServer
sudo docker start VpnHoodServer

The same log is written to /opt/VpnHoodServer/storage/logs/server.log on the host.

Change the settings

The server reads its settings from /opt/VpnHoodServer/storage/appsettings.json. Edit the file, then restart the container with sudo docker restart VpnHoodServer.

Where you cannot edit a file, put the whole content of an appsettings.json in the VH_APPSETTINGS environment variable instead. The server then uses it in place of the file.

Set your server's IP addresses and Connect through a domain name walk through the settings you are most likely to change.

Updates

The server updates itself inside the container. It checks for a new release when it starts and every 12 hours, and restarts into the new version.

To stay on one version, set VH_AUTO_UPDATE=0 in the container's environment.

Now and then a release needs a newer image. The server then keeps its current version, and its log says Pull the latest image! Run the install command again: it pulls the latest image and creates the container again, with the same settings and keys.

If you installed with an earlier version of the script, run the install command again. It moves the server to the new image and removes the old VpnHoodUpdater container.

Create the container yourself

If you manage your containers by hand, this is the container the installer creates. Run it on the host's network, as the installer does.

sudo docker run -d --name VpnHoodServer --network host --restart always --stop-timeout 30 -v /opt/VpnHoodServer/storage:/app/storage vpnhood/vpnhoodserver

To move it to a newer image, pull vpnhood/vpnhoodserver and create the container again.

Next steps