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.
Before you begin, you need to meet the following prerequisites:
The first step is to install Docker on OpenBSD. To do so, run the following command:
$ sudo pkg_add docker
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
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
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
YOUR_TIMEZONE
: Set the timezone for your server.YOUR_DOMAIN_NAME
: Set your domain name.YOUR_USER_ID
: Set your user ID.YOUR_GROUP_ID
: Set your group ID.YOUR_EMAIL_ADDRESS
: Set your email address.YOUR_CLOUDFLARE_EMAIL_ADDRESS
, YOUR_CLOUDFLARE_API_KEY
, and YOUR_CLOUDFLARE_API_TOKEN
are required if you plan to use Cloudflare for DNS authentication. If not, you can remove the DNSPLUGIN
and CF_API_*
variables.Once you have set the variables, save and close the file.
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.
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!