Files
pad/deploy/nginx.conf
T
xarmian af2755d5af docs: add deployment documentation, Docker Compose, and K8s manifests
Provide production-ready deployment configurations:
- docker-compose.yml: Pad + PostgreSQL + Redis single-command setup
- docker-compose.prod.yml: production overlay with resource limits
- deploy/k8s/: Kubernetes manifests (deployment, service, ingress, HPA)
- deploy/Caddyfile: Caddy reverse proxy with auto-TLS
- deploy/nginx.conf: nginx config with SSE-friendly proxy settings
- docs/deployment.md: environment variable reference, architecture
  diagram, quick start, production checklist
2026-04-06 01:58:04 +00:00

84 lines
2.5 KiB
Nginx Configuration File

# Pad — nginx reverse proxy
#
# Usage:
# 1. Replace "pad.example.com" with your domain
# 2. Update ssl_certificate paths to your TLS certs
# 3. Include this file in your nginx config or copy to /etc/nginx/conf.d/
#
# Key settings for SSE support:
# - proxy_buffering off
# - proxy_read_timeout 86400s (24h for long-lived SSE connections)
# - proxy_http_version 1.1 with Connection ""
upstream pad_backend {
server 127.0.0.1:7777;
# For Docker: server pad:7777;
keepalive 32;
}
server {
listen 80;
server_name pad.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name pad.example.com;
ssl_certificate /etc/ssl/certs/pad.example.com.pem;
ssl_certificate_key /etc/ssl/private/pad.example.com-key.pem;
# Modern TLS settings
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Gzip
gzip on;
gzip_types text/plain application/json text/css application/javascript;
# SSE endpoint — requires special proxy settings
location /api/v1/events {
proxy_pass http://pad_backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Critical for SSE:
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
chunked_transfer_encoding on;
}
# All other routes
location / {
proxy_pass http://pad_backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_read_timeout 60s;
# File uploads
client_max_body_size 10M;
}
access_log /var/log/nginx/pad-access.log;
error_log /var/log/nginx/pad-error.log;
}