← Retour
# ═══════════════════════════════════════════════════════════════════════════
# {{NAME}} - API Backend Configuration
# Auto-generated by smart-deploy.sh
# ═══════════════════════════════════════════════════════════════════════════
# Rate limiting zone
limit_req_zone $binary_remote_addr zone={{NAME}}_limit:10m rate=10r/s;
# Redirect HTTP to HTTPS
server {
listen 80;
server_name {{DOMAIN}};
return 301 https://$server_name$request_uri;
}
# HTTPS Server
server {
listen 443 ssl http2;
server_name {{DOMAIN}};
# SSL Configuration
ssl_certificate {{SSL_CERT}};
ssl_certificate_key {{SSL_KEY}};
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
# Security Headers
add_header X-Frame-Options "DENY" 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/{{NAME}}.access.log;
error_log /var/log/nginx/{{NAME}}.error.log;
# API endpoint
location / {
# Rate limiting
limit_req zone={{NAME}}_limit burst=20 nodelay;
proxy_pass http://{{BACKEND}}:{{PORT}};
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;
# CORS headers (if needed)
# add_header Access-Control-Allow-Origin "*" always;
# add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
# add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
# Timeouts
proxy_connect_timeout 60s;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
# Body size for uploads
client_max_body_size 50M;
}
# Health check endpoint (no rate limit)
location /health {
proxy_pass http://{{BACKEND}}:{{PORT}}/health;
proxy_set_header Host $host;
access_log off;
}
}