In this tutorial, we will guide you through the process of installing SWAG (Secure Web Application Gateway) on Debian Latest. SWAG is a docker container that manages the reverse proxy, SSL, and authentication of all your web applications.
Before we can install SWAG, we need to ensure that we have the following:
First, we need to clone the SWAG repository to our local system. To do this, run the following command:
git clone https://github.com/linuxserver/docker-swag.git
This will clone the SWAG repository to a directory named docker-swag
.
Next, we need to configure SWAG by editing the .env
file located in the docker-swag
directory. Open the .env
file in your favorite text editor and replace the example values with your own. The following variables need to be updated:
URL
: The domain name of your server.SUBDOMAINS
: A comma-separated list of subdomains for your web applications.EMAIL
: Your email address for SSL certificate generation.For example, to configure SWAG with the example.com
domain, with the www
subdomain and the blog
subdomain, and your email address, user@example.com
, your .env
file should look like:
URL=example.com
SUBDOMAINS=www,blog
EMAIL=user@example.com
After updating the values, save and close the file.
Now that we have configured SWAG, we can start the container by running the following command:
docker-compose up -d
This will start the SWAG container in the background. It may take a few minutes to complete if this is the first time running the container.
Once SWAG is up and running, we can add our web applications to it. To do this, we need to create a new configuration file for each web application.
Create a new file in the docker-swag/nginx/proxy-confs
directory with the name of your web application, followed by .subdomain.conf
. For example, if your web application is named myapp
, the filename would be myapp.subdomain.conf
.
In this file, we need to define the location of the web application and any additional configurations. Here is an example configuration file for a web application running on port 8000
:
# myapp.subdomain.conf
server {
listen 443 ssl;
server_name myapp.example.com;
include /config/nginx/ssl.conf;
client_max_body_size 0;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Be sure to replace myapp.example.com
with your own subdomain and domain name. Save and close the file when finished.
After creating the configuration file, restart the SWAG container by running the following command:
docker-compose restart
Your web application should now be accessible through the subdomain myapp.example.com
.
Congratulations! You have successfully installed SWAG on your Debian Latest server and added your first web application to it. You can now add more web applications by creating new configuration files and restarting the SWAG container.
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!