|
| 1 | +# Nginx configuration template for Nostream relay |
| 2 | +# ${RELAY_DOMAIN} is substituted automatically by the start script |
| 3 | + |
| 4 | +map $http_upgrade $connection_upgrade { |
| 5 | + default upgrade; |
| 6 | + '' close; |
| 7 | +} |
| 8 | + |
| 9 | +# HTTP — redirect to HTTPS and serve ACME challenge for Let's Encrypt |
| 10 | +server { |
| 11 | + listen 80; |
| 12 | + server_name ${RELAY_DOMAIN}; |
| 13 | + |
| 14 | + location /.well-known/acme-challenge/ { |
| 15 | + root /var/www/certbot; |
| 16 | + } |
| 17 | + |
| 18 | + location / { |
| 19 | + return 301 https://$host$request_uri; |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +# HTTPS — reverse proxy to nostream relay |
| 24 | +server { |
| 25 | + listen 443 ssl; |
| 26 | + server_name ${RELAY_DOMAIN}; |
| 27 | + |
| 28 | + ssl_certificate /etc/nginx/ssl/live/${RELAY_DOMAIN}/fullchain.pem; |
| 29 | + ssl_certificate_key /etc/nginx/ssl/live/${RELAY_DOMAIN}/privkey.pem; |
| 30 | + |
| 31 | + ssl_protocols TLSv1.2 TLSv1.3; |
| 32 | + ssl_ciphers HIGH:!aNULL:!MD5; |
| 33 | + ssl_prefer_server_ciphers on; |
| 34 | + |
| 35 | + location / { |
| 36 | + proxy_pass http://nostream:8008; |
| 37 | + |
| 38 | + # WebSocket support |
| 39 | + proxy_http_version 1.1; |
| 40 | + proxy_set_header Upgrade $http_upgrade; |
| 41 | + proxy_set_header Connection $connection_upgrade; |
| 42 | + |
| 43 | + # Pass client IP to relay |
| 44 | + proxy_set_header Host $host; |
| 45 | + proxy_set_header X-Real-IP $remote_addr; |
| 46 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 47 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 48 | + |
| 49 | + # WebSocket timeouts |
| 50 | + proxy_read_timeout 86400s; |
| 51 | + proxy_send_timeout 86400s; |
| 52 | + } |
| 53 | +} |
0 commit comments