Back to articles
DevOps & Systems

Professional Web-Based VPN Server Setup with Firezone and WireGuard UI on Ubuntu

This guide provides a detailed walkthrough for setting up a professional VPN server on Ubuntu using Firezone, an open-source WireGuard-based VPN platform with a web interface,...

DPTCloud Engineering4 min read
Professional Web-Based VPN Server Setup with Firezone and WireGuard UI on Ubuntu

Image credit: StefanCoders · Pixabay Content License

This guide provides a detailed walkthrough for setting up a professional VPN server on Ubuntu using Firezone, an open-source WireGuard-based VPN platform with a web interface, combined with WireGuard UI for intuitive device management. The setup includes installation, configuration, user and device management, and security optimization for businesses or individuals requiring secure remote access. The process leverages Docker and Docker Compose for containerized deployment and integrates with Nginx for reverse proxying, ensuring scalability and ease of maintenance.

Requirements and Environment Preparation

To successfully deploy a Firezone and WireGuard UI VPN server on Ubuntu, you need an Ubuntu 22.04 or 20.04 (64-bit) system with root access and a stable internet connection. The system must be updated and have essential tools installed, including Docker, Docker Compose, and Nginx, to support containerized services and reverse proxy functionality. You can use NVMe Cloud VPS for Docker, Nginx & Databases to ensure optimal performance for these services.

Installing Firezone on Ubuntu

Firezone is an open-source VPN platform built on WireGuard, offering a web-based management interface for simplified deployment and operations. To install, first install Docker and Docker Compose:

sudo apt update
sudo apt install -y docker.io docker-compose
sudo systemctl enable docker
sudo systemctl start docker

Next, create a working directory and generate a docker-compose.yml file:

mkdir firezone && cd firezone
nano docker-compose.yml

Insert the following content into the file:

version: '3.8'
services:
  firezone:
    image: firezone/firezone:latest
    container_name: firezone
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./data:/data
    restart: unless-stopped
    environment:
      - FIREZONE_DB_URL=postgresql://firezone:firezone@db:5432/firezone
      - FIREZONE_REDIS_URL=redis://redis:6379
      - FIREZONE_WIREGUARD_INTERFACE=wg0
    depends_on:
      - db
      - redis
  db:
    image: postgres:13
    container_name: firezone-db
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: firezone
      POSTGRES_USER: firezone
      POSTGRES_PASSWORD: firezone
    restart: unless-stopped
  redis:
    image: redis:6-alpine
    container_name: firezone-redis
    restart: unless-stopped

Run the following command to start the services:

docker-compose up -d

After startup, access http://your-server-ip to reach the Firezone management interface for the first time. Set up the initial user and password.

Integrating WireGuard UI for Device Management

WireGuard UI is an open-source web interface that enables intuitive management of WireGuard-connected devices. To integrate it, create a separate container for WireGuard UI:

mkdir wireguard-ui && cd wireguard-ui
nano docker-compose.yml

Insert the following content into the file:

version: '3.8'
services:
  wireguard-ui:
    image: linuxserver/wireguard-ui:latest
    container_name: wireguard-ui
    ports:
      - "5000:5000"
    volumes:
      - ./config:/config
    environment:
      - TZ=Asia/Ho_Chi_Minh
      - WIREGUARD_UI_USERNAME=admin
      - WIREGUARD_UI_PASSWORD=yourpassword
    restart: unless-stopped

Start the container:

docker-compose up -d

Access http://your-server-ip:5000 to log in and configure WireGuard devices. You can connect to Firezone via API or set up a private network to manage devices from a single interface.

Testing and Verification

After installation, verify that all services are running correctly using the command:

docker-compose ps

Ensure all containers are in the "Up" state. Then, access the Firezone interface to create a new user. Download the WireGuard configuration for a device, install it, and connect. Test the connection using:

ping 8.8.8.8

If the connection succeeds, the setup is complete. You can enhance security by enabling GeoIP blocking with nftables, as detailed in Hướng dẫn cấu hình chặn IP theo quốc gia GeoIP blocking bằng nftables trên Linux server.

Troubleshooting and Notes

  • Ensure ports 80, 443, and 5000 are not blocked by the firewall.
  • Restart Docker if services fail to start.
  • Verify that the /data and /config directories have read/write permissions.
  • In case of connection issues, check logs using docker-compose logs firezone.

Firezone and WireGuard UI provide an effective solution for building a professional VPN server with a modern web interface, suitable for small businesses, organizations, or individuals needing secure remote access.

DPTCloud Tier III Infrastructure

Recommended NVMe Cloud VPS Plans to Deploy This Setup

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02

VPS-2E

94.600 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 2 GB
  • SSD: 30 GB NVMe
ECO · vn-02Recommended

VPS-3E

170.500 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 4 GB
  • SSD: 50 GB NVMe
BASIC · vn-01Recommended

VPS-05

457.600 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478