How to Install SWAG (Secure Web Application Gateway) on POP! OS Latest

SWAG (Secure Web Application Gateway) is an easy-to-use Docker-based tool that allows you to easily and securely access your web applications over HTTPS. It provides automated Let's Encrypt SSL certificates, reverse proxy, and various security features to ensure your web applications are protected.

This tutorial will guide you through the installation process of SWAG on your POP! OS Latest.

Prerequisites

To follow along with this tutorial, you will need:

Step 1: Install Docker

To install Docker on your POP! OS Latest, follow the instructions on the Docker website or run the following commands:

sudo apt-get update
sudo apt-get install docker.io

You should also enable Docker to start automatically on boot:

sudo systemctl enable docker

Step 2: Install Docker Compose

To install Docker Compose, run the following commands:

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Verify the installation by checking the version of Docker Compose:

docker-compose --version

Step 3: Install SWAG

SWAG is available as a Docker image from the LinuxServer.io Docker Hub.

Create a new directory for SWAG and move to it:

mkdir swag
cd swag

Create a docker-compose.yml file to configure the SWAG service:

version: "3"
services:
  swag:
    image: ghcr.io/linuxserver/swag
    container_name: swag
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - URL=example.com
      - SUBDOMAINS=www
      - VALIDATION=http
      - EMAIL=your-email@example.com
      - STAGING=false
    volumes:
      - /path/to/appdata/config:/config
      - /path/to/letsencrypt:/ssl
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    restart: unless-stopped

Make sure to replace the URL, SUBDOMAINS, EMAIL, and the volumes paths with your own configuration.

The PUID and PGID environment variables determine the user ID and group ID that the process runs as. In this example, it is set to 1000, which is the default user on most Linux distributions.

Save the docker-compose.yml file and start the SWAG service:

sudo docker-compose up -d

This command downloads the SWAG Docker image and starts the container as a daemon in the background.

Check the status of the SWAG container:

sudo docker ps -a

You should see the swag container in the list of running containers.

Step 4: Configure Your Web Applications

Now that SWAG is up and running, you need to configure your web applications to use it.

The simplest way to do this is to change the ports your web applications listen on from 80 and 443 to a different port number, such as 8080.

For example, if you have a web application running on port 80, you can configure it to listen on port 8080 by changing the configuration file for the web server (such as nginx.conf or apache2.conf) to include the following line:

listen 8080;

You can then access your web application securely over HTTPS by visiting https://example.com:8080, where example.com is your domain name and 8080 is the port number your web application is listening on.

Conclusion

In this tutorial, you learned how to install SWAG on your POP! OS Latest using Docker Compose, and how to configure your web applications to use it. With SWAG, you can easily and securely access your web applications over HTTPS, with automated Let's Encrypt SSL certificates and reverse proxy.

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!