This directory contains a complete SWAG (LinuxServer.io nginx) reverse proxy setup for the homelab with 37+ pre-configured services.
SWAG (Secure Web Application Gateway) is a nginx-based reverse proxy with:
SWAG-reverse-proxy/
βββ swag-configs/ # Auto-generated subdomain configs (37+ services)
β βββ vault.subdomain.conf # Vaultwarden configuration
β βββ photos.subdomain.conf # Immich photo service
β βββ plex.subdomain.conf # Plex media server
β βββ ... # All other services
βββ docker-compose.yml # SWAG deployment configuration
βββ cloudflare.ini.template # CloudFlare credentials template
βββ fix-swag-configs.sh # Configuration fix script
βββ cleanup-swag-configs.sh # Configuration cleanup utility
βββ README.md # This file
# Copy the template
cp cloudflare.ini.template cloudflare.ini
# Edit with your credentials
nano cloudflare.ini
Add your CloudFlare API token:
dns_cloudflare_api_token = YOUR_CLOUDFLARE_API_TOKEN_HERE
# Start SWAG with fail2ban
docker-compose up -d
# Check logs
docker-compose logs -f swag
# Check nginx configuration syntax
docker exec swag nginx -t
# Reload nginx after any config changes
docker exec swag nginx -s reload
Each service follows this standard SWAG subdomain format:
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name service.piyushmehta.com;
include /config/nginx/ssl.conf;
client_max_body_size 0;
# Security headers
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
add_header X-Frame-Options SAMEORIGIN always;
add_header X-Content-Type-Options nosniff always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
location / {
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
set $upstream_app 192.168.0.xxx;
set $upstream_port xxxx;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
# WebSocket support
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
Media & Entertainment:
vault.piyushmehta.com
β Vaultwarden (192.168.0.248:8000)photos.piyushmehta.com
β Immich (192.168.0.4:2283)plex.piyushmehta.com
β Plex Media Server (192.168.0.4:32400)jellyfin.piyushmehta.com
β Jellyfin (192.168.0.4:8096)Automation & Downloads:
request.piyushmehta.com
β Overseerr (192.168.0.120:5055)qbit.piyushmehta.com
β qBittorrent (192.168.0.107:6969)sonarr.piyushmehta.com
β Sonarr (192.168.0.120:8989)radarr.piyushmehta.com
β Radarr (192.168.0.120:7878)Development & AI:
a1111.piyushmehta.com
β Stable Diffusion WebUI (192.168.0.124:8090)ollama.piyushmehta.com
β Ollama AI (192.168.0.124:11434)git.piyushmehta.com
β Gitea (192.168.0.151:3000)And many moreβ¦ (see individual .subdomain.conf files for complete list)
nginx syntax errors:
./fix-swag-configs.sh
Certificate generation failures:
docker-compose logs swag
Service not accessible:
curl http://192.168.0.xxx:port
# Test nginx configuration
docker exec swag nginx -t
# Reload nginx configuration
docker exec swag nginx -s reload
# View certificate status
docker exec swag certbot certificates
# Force certificate renewal
docker exec swag certbot renew --force-renewal
# Check fail2ban status
docker exec fail2ban fail2ban-client status
# View blocked IPs
docker exec fail2ban fail2ban-client status nginx-http-auth
/opt/swag/log/nginx/access.log
/opt/swag/log/nginx/error.log
/opt/fail2ban/log/fail2ban.log
Stop NPMplus:
docker-compose down
Update DNS (if needed):
Deploy SWAG:
cd SWAG-reverse-proxy
docker-compose up -d
Verify services:
Create a new subdomain config:
cp swag-configs/template.subdomain.conf swag-configs/newservice.subdomain.conf
Edit the configuration:
Reload nginx:
docker exec swag nginx -s reload
.subdomain.conf
filedocker exec swag nginx -t
docker exec swag nginx -s reload
/opt/swag
directory (contains certificates and logs)swag-configs/
directoryFor issues with: