- PM2 cluster mode (2 API workers + 1 Next.js) - Nginx reverse proxy with SSL, rate limiting, security headers - Automated backup script with daily/weekly rotation - PostgreSQL production tuning script (300 connections, 4GB shared_buffers) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
90 lines
2.9 KiB
Plaintext
90 lines
2.9 KiB
Plaintext
# Rate limiting zones
|
|
limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s;
|
|
limit_req_zone $binary_remote_addr zone=auth:10m rate=5r/s;
|
|
limit_req_zone $binary_remote_addr zone=webhook:10m rate=10r/s;
|
|
|
|
upstream horux_api {
|
|
server 127.0.0.1:4000;
|
|
}
|
|
|
|
upstream horux_web {
|
|
server 127.0.0.1:3000;
|
|
}
|
|
|
|
# Redirect HTTP to HTTPS
|
|
server {
|
|
listen 80;
|
|
server_name horux360.consultoria-as.com;
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl http2;
|
|
server_name horux360.consultoria-as.com;
|
|
|
|
# SSL (managed by Certbot)
|
|
ssl_certificate /etc/letsencrypt/live/horux360.consultoria-as.com/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/horux360.consultoria-as.com/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
|
|
|
|
# Security headers
|
|
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;
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
# Max body size for XML uploads
|
|
client_max_body_size 1G;
|
|
|
|
# Auth endpoints (stricter rate limiting)
|
|
location /api/auth/ {
|
|
limit_req zone=auth burst=10 nodelay;
|
|
proxy_pass http://horux_api;
|
|
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;
|
|
}
|
|
|
|
# Webhook endpoints (no auth, moderate rate limiting)
|
|
location /api/webhooks/ {
|
|
limit_req zone=webhook burst=20 nodelay;
|
|
proxy_pass http://horux_api;
|
|
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;
|
|
}
|
|
|
|
# API routes
|
|
location /api/ {
|
|
limit_req zone=api burst=50 nodelay;
|
|
proxy_pass http://horux_api;
|
|
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_read_timeout 300s;
|
|
}
|
|
|
|
# Health check (no rate limit)
|
|
location /health {
|
|
proxy_pass http://horux_api;
|
|
}
|
|
|
|
# Next.js frontend
|
|
location / {
|
|
proxy_pass http://horux_web;
|
|
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_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
}
|