Back to services

SWAG (Secure Web Application Gateway)

Nginx webserver and reverse proxy with PHP support, built-in Certbot (Let's Encrypt) client and fail2ban integration.

View alternatives to SWAG (Secure Web Application Gateway)
Suggest edit
Open source
Self-hostable
GPL-3.0
Recent reviews

Alternatives

Tech stack

No tech stack added yet. Sign in to suggest some

Note: We couldn't fetch the official website (the GitHub repository page), so the following is compiled from existing knowledge of the project. For specific parameters and the latest features, please refer to the official repository and the LinuxServer.io documentation.

Introduction

SWAG (Secure Web Application Gateway) is a Docker image maintained by the LinuxServer.io community, and the successor to their letsencrypt image. It bundles Nginx (web server and reverse proxy), PHP, Certbot (automatic certificate issuance and renewal) and fail2ban (intrusion prevention) into a single container. Without configuring each of these components separately, users can add HTTPS access and basic security protection to their self-hosted services.

Key Features

  • Automatic SSL certificate management: Certbot is built in, so you can obtain free certificates from Let's Encrypt or ZeroSSL and have them renewed automatically.
  • Two validation methods: Supports both HTTP validation and DNS validation. DNS plugins support many DNS providers, such as Cloudflare, and let you obtain wildcard certificates.
  • Nginx reverse proxy: Puts multiple internal services behind port 443 and routes traffic by subdomain or subpath.
  • Preconfigured proxy templates: Ships with a large collection of sample reverse proxy configurations (proxy-confs) for popular self-hosted apps, such as Nextcloud, Jellyfin and Home Assistant. Usually you just rename a file to enable it.
  • fail2ban protection: Monitors Nginx logs and automatically bans IPs with repeated authentication failures or malicious behavior.
  • PHP support: Can host static sites or PHP sites directly.
  • Docker Mods extensions: You can add extra features using LinuxServer's Docker Mods mechanism, such as auto-proxy, dashboards, geo-blocking and CrowdSec integration.

Target Users and Use Cases

Suited to self-hosting users who deploy home servers, NAS devices or VPSes with Docker. It fits these needs:

  • Securely accessing multiple internal services from the internet through a domain name and HTTPS;
  • Not wanting to handle certificate issuance and renewal manually;
  • Wanting a single container that covers reverse proxying, certificates and basic security protection.

Deployment

Docker Compose is recommended. Here is an example:

services:
  swag:
    image: lscr.io/linuxserver/swag:latest
    container_name: swag
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Shanghai
      - URL=example.com
      - SUBDOMAINS=wildcard
      - VALIDATION=dns
      - DNSPLUGIN=cloudflare
      - [email protected]
    volumes:
      - ./config:/config
    ports:
      - 443:443
      - 80:80
    restart: unless-stopped

After the first start, the container requests certificates automatically. All configuration (including Nginx site configs, proxy-confs, fail2ban rules and certificates) is stored in the /config directory, which makes backup and migration easy.

Common environment variables:

  • URL: the main domain
  • SUBDOMAINS: a list of subdomains, or wildcard to request a wildcard certificate
  • VALIDATION: the validation method, either http or dns
  • DNSPLUGIN: the DNS provider plugin
  • ONLY_SUBDOMAINS: whether to request certificates for subdomains only
  • EXTRA_DOMAINS: additional domains
  • STAGING: whether to use the staging environment, useful for debugging and for avoiding certificate rate limits

Technical Requirements

  • Docker or Docker Compose installed;
  • A domain name of your own;
  • With HTTP validation, port 80 must be reachable from the internet; with DNS validation, you need API credentials from your DNS provider;
  • For fail2ban to work properly, the container needs the NET_ADMIN capability.

Notable Points

  • Follows the common conventions of LinuxServer.io images, including PUID/PGID permission mapping and regular updates, and provides multi-architecture images (such as x86-64 and arm64);
  • SWAG is typically placed on the same Docker network as your other application containers, so you can use container names directly as proxy targets;
  • Compared with solutions such as Nginx Proxy Manager, Traefik and Caddy, SWAG is based on standard Nginx configuration files, which makes it very flexible, but it has no graphical interface, so it suits users who are comfortable editing configuration files;
  • Released under the GPL-3.0 open-source license.