Installing WireGuard with Docker Compose on Ubuntu 22.04 with 6 steps.
Like OpenVPN or IPSec, WireGuard is a free VPN system that helps you establish an encrypted connection between the client and the server via an Internet connection. WireGuard operates at layer 3, designed as a virtual network interface of the Kernel for Linux. WireGuard was created as an alternative to IPSec in most use cases and relied on TLS-based solutions like OpenVPN, while WireGuard is more secure, faster, and easier to use.
And in this article, AZDIGI will guide you to install WireGuard with Docker Compose on Ubuntu 22.04, please follow along.
Conditions the server needs to meet:
- Linux server (In this article, I will install on Ubuntu 22.04)
- Install Docker
- Install Docker Compose
- Public IP
If the above conditions are met, we will proceed to install and configure WireGuard.
Step 1: Install WireGuard
- First, you need to create a folder containing the project and name it to your liking. For example, I will name it WireGuard
mkdir /home/WireGuard/.wg-easy cd /home/WireGuard/.wg-easy
- Next, download the file docker-compose.yml fromWeeJeWel/wg-easy on github with the command below:
- Edit access path and WireGuard UI login information
To edit the WireGuard UI login information, proceed to edit the content of the docker-compose.yml file as follows:
sudo nano docker-compose.yml
You find and edit the User/Password information to the information you want and save it.
- WG_HOST= Nhập tên miền bạn muốn truy cập vào Web UI - PASWORD= Nhập mật khẩu đăng nhập Web UI
For example, I set WG_HOST to wireguard.azdigi.space and PASSWORD to wireguard_passwd.
Step 2: Enable WireGuard
After editing the information is complete, now run the command below to enable WireGuard:
docker-compose up --detach
The run will take a few minutes, and if successful, you will receive a message below:
Now go to the browser and use the address <a href=”http://http://Server-IP:51821 or the previously set WG_HOST address to access WireGuard UI. have configured WG_HOST with the address wireguard.azdigi.space, so I will go to http://wireguard.azdigi.space:51821.
Now, you log in with the information declared in the PASSWORD section of the docker-compose.yml file.
After successful login, you will see the WireGuard UI interface as below:
Step 3: Create WireGuard Client
As you can see the WireGuard management Web UI interface is extremely friendly and easy to use. Here are some features you need to keep in mind when using Web UI:
- Create WireGuard Client
To create a new Client, you need to click New Client => give it a name => click Create.
- Click on the QR icon to see the QR code used to set up the WireGuard client on your phone.
- Click the Download icon to download the configuration file, which is used to set up the WireGuard client on the computer.
- Click the Trash icon to delete the client.
Step 4: Configure NAT Port for WireGuard
To be able to connect to the WireGuard VPN Server from the outside, you must configure the open port on the network router (if WireGuard is installed on the server at home), or configure the firewall if installed on the virtual server.
Here I’m installing it to a VPS service at AZDIGI, so I will open port 51820 on VPS with the following command:
sudo ufw allow 51820/udp
Step 5: Setup & use WireGuard
1. Set up & use WireGuard on the computer
Before setting up, you need to have the WireGuard application. And you can download WireGuard from the WireGuard homepage for operating system platforms:
After downloading and installing the WireGuard software application on the client computer, click the
+ sign => select
Import Tunnel(s) from File to add configuration.
2. Set up & use WireGuard on mobile
WireGuard is also available on mobile devices. To download, please visit the corresponding link below:
- Create from QR code: Scan the QR code.
- Create from file or archive: Import the configuration file.
Step 6: Check the internet connection
After the connection is complete, I will access the Internet to check if it works and if the IP is correct.
So AZDIGI has completed installing WireGuard with Docker Compose on Ubuntu 22.04. Wishing you success!
You can refer to other user manuals at the link below
If you need support, you can contact support in the ways below:
- Hotline 247: 028 730 24768 (Ext 0)
- Ticket/Email: You use the email to register for the service and send it directly to: firstname.lastname@example.org