SWAG (Secure Web Application Gateway) is a docker container from Linuxserver that acts as a reverse proxy and provides easy SSL encryption for your web applications. In this tutorial, we will walk you through the steps to install SWAG on Ubuntu Server Latest.
To follow this tutorial, you should have:
We will create a directory to store the SWAG configuration files. In the terminal, run:
sudo mkdir -p /mnt/docker/swag
We will download the SWAG configuration files from the Linuxserver repository on GitHub. In the terminal, run:
sudo curl https://raw.githubusercontent.com/linuxserver/docker-swag/master/config/nginx/site-confs/default > /mnt/docker/swag/nginx/site-confs/default
sudo curl https://raw.githubusercontent.com/linuxserver/docker-swag/master/config/nginx/site-confs/subdomain.template > /mnt/docker/swag/nginx/site-confs/subdomain.template
sudo curl https://raw.githubusercontent.com/linuxserver/docker-swag/master/config/nginx/keys/dhparams.pem > /mnt/docker/swag/nginx/keys/dhparams.pem
We will create the SWAG docker-compose.yml file and configure it to use the SWAG configuration files. In the terminal, run:
sudo vi /mnt/docker/swag/docker-compose.yml
Copy and paste the following code into the file:
version: "2.1"
services:
swag:
image: linuxserver/swag
container_name: swag
restart: unless-stopped
ports:
- 80:80
- 443:443
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London #change this to your timezone
- URL=your-domain.com #change this to your domain name
- SUBDOMAINS=wildcard
- VALIDATION=http
volumes:
- /mnt/docker/swag/nginx:/config
Save the file and exit the editor.
In the environment section, replace PUID
and PGID
with your user ID and group ID. You can find them by running the id
command in the terminal. Replace TZ
with your timezone.
In the URL
field, replace your-domain.com
with your own domain name. In the SUBDOMAINS
field, set it to wildcard
if you want to create subdomains automatically. Set it to www,subdomain,your-domain
if you want to create subdomains manually.
We will start the SWAG container using the docker-compose.yml file we created. In the terminal, run:
cd /mnt/docker/swag
sudo docker-compose up -d
This command will start the SWAG container in detached mode, meaning it will run in the background.
To verify that SWAG is installed and running properly, open a web browser and go to https://your-domain.com
. You should see the default NGINX welcome page with a padlock icon in the address bar, indicating that the connection is secure.
If you want to add a web application to SWAG, follow these steps:
/mnt/docker/swag/nginx/site-confs/
subdomain.template
file to the new directory and rename it to appName.conf
appName.conf
file to point to the correct IP address and port of your applicationsudo docker-compose restart
Congratulations, you have successfully installed SWAG on Ubuntu Server Latest and added a web application to it.
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!