| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- # Smartbotic Nginx Configuration
- # This file is managed by Smartbotic installer
- # Domain: {{DOMAIN}}
- # Rate limiting
- limit_req_zone $binary_remote_addr zone=api_limit:10m rate=100r/s;
- limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
- # Upstream definition
- upstream smartbotic_http {
- server 127.0.0.1:8090;
- keepalive 32;
- }
- # HTTP -> HTTPS redirect
- server {
- listen 80;
- listen [::]:80;
- server_name {{SERVER_NAMES}};
- # Let's Encrypt challenge
- location /.well-known/acme-challenge/ {
- root /var/www/certbot;
- }
- # Redirect all other traffic to HTTPS
- location / {
- return 301 https://$host$request_uri;
- }
- }
- # HTTPS server
- server {
- listen 443 ssl;
- listen [::]:443 ssl;
- http2 on;
- server_name {{SERVER_NAMES}};
- # SSL certificates (managed by certbot)
- ssl_certificate /etc/letsencrypt/live/{{DOMAIN}}/fullchain.pem;
- ssl_certificate_key /etc/letsencrypt/live/{{DOMAIN}}/privkey.pem;
- ssl_trusted_certificate /etc/letsencrypt/live/{{DOMAIN}}/chain.pem;
- # Modern SSL configuration
- 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:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
- ssl_prefer_server_ciphers off;
- ssl_session_timeout 1d;
- ssl_session_cache shared:SSL:50m;
- ssl_session_tickets off;
- # OCSP stapling
- ssl_stapling on;
- ssl_stapling_verify on;
- resolver 1.1.1.1 8.8.8.8 valid=300s;
- resolver_timeout 5s;
- # Security headers
- add_header Strict-Transport-Security "max-age=63072000" 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;
- # Logging
- access_log /var/log/nginx/smartbotic_access.log;
- error_log /var/log/nginx/smartbotic_error.log;
- # Client settings
- client_max_body_size 50M;
- client_body_timeout 60s;
- client_header_timeout 60s;
- # Gzip compression
- gzip on;
- gzip_vary on;
- gzip_proxied any;
- gzip_comp_level 6;
- gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
- # API endpoints
- location /api/ {
- limit_req zone=api_limit burst=50 nodelay;
- limit_conn conn_limit 100;
- proxy_pass http://smartbotic_http;
- proxy_http_version 1.1;
- 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_set_header Connection "";
- proxy_read_timeout 300s;
- proxy_send_timeout 300s;
- proxy_connect_timeout 60s;
- proxy_buffering off;
- }
- # WebUI static files and SPA fallback
- location / {
- proxy_pass http://smartbotic_http;
- proxy_http_version 1.1;
- 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_set_header Connection "";
- # Cache static assets
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
- proxy_pass http://smartbotic_http;
- proxy_cache_valid 200 1d;
- add_header Cache-Control "public, max-age=86400";
- }
- }
- # Health check endpoint (no rate limit)
- location /health {
- proxy_pass http://smartbotic_http/api/v1/health;
- proxy_http_version 1.1;
- proxy_set_header Host $host;
- proxy_set_header Connection "";
- }
- }
|