How to Install SWAG (Secure Web Application Gateway) on OpenBSD

In this tutorial, you will learn how to install SWAG (Secure Web Application Gateway) on OpenBSD from https://github.com/linuxserver/docker-swag. SWAG is an HTTPS reverse-proxy with automated Let's Encrypt, DNS and optional failover support.

Prerequisites

Before you begin, you need to meet the following prerequisites:

Step 1: Install Docker

The first step is to install Docker on OpenBSD. To do so, run the following command:

$ sudo pkg_add docker

Step 2: Install Docker Compose

Now we need to install Docker Compose. Docker Compose is a tool for defining and running multi-container Docker applications. To install it, run the following commands:

$ sudo pkg_add py3-pip
$ sudo pip3 install docker-compose

Step 3: Clone the SWAG Repository

Next, we need to clone the SWAG repository from GitHub. To clone it, run the following command:

$ git clone https://github.com/linuxserver/docker-swag.git

Step 4: Configure the SWAG Environment Variables

We need to set up the SWAG environment variables before we can run it. To do so, navigate to the docker-swag directory and create a .env file:

$ cd docker-swag
$ cp env.example .env

Edit the .env file and set the following variables:

TZ=YOUR_TIMEZONE
URL=YOUR_DOMAIN_NAME
SUBDOMAINS=www,example
PUID=YOUR_USER_ID
PGID=YOUR_GROUP_ID
EMAIL=YOUR_EMAIL_ADDRESS
STAGING=false
DNSPLUGIN=cloudflare
CF_API_EMAIL=YOUR_CLOUDFLARE_EMAIL_ADDRESS
CF_API_KEY=YOUR_CLOUDFLARE_API_KEY
CF_API_TOKEN=YOUR_CLOUDFLARE_API_TOKEN

Once you have set the variables, save and close the file.

Step 5: Start the SWAG Container

Now that we have set up the environment variables, we can start the SWAG container. To start it, run the following command:

$ docker-compose up -d

This command will start the SWAG container in the background. You can check the status of the container using the following command:

$ docker-compose ps

If the container is running, you should see output similar to the following:

     Name                   Command                 State                Ports              
--------------------------------------------------------------------------------------------
docker-swag_letsencrypt   /sbin/tini -- /usr/bin/d ...   Up       80/tcp, 0.0.0.0:443->443/tcp
docker-swag_nginx         /sbin/tini -- /usr/bin/d ...   Up       0.0.0.0:80->80/tcp        
docker-swag_watchtower    /usr/bin/watchtower             Up       0.0.0.0:8080->8080/tcp  

Congratulations! You have successfully installed SWAG on OpenBSD.

Conclusion

In this tutorial, we have learned how to install SWAG on OpenBSD from https://github.com/linuxserver/docker-swag. With SWAG, you can now securely and easily set up reverse-proxy servers for your applications.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!