Governed substrate for autonomous agents: scoped identity (passports), audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
128 lines
4.5 KiB
Text
128 lines
4.5 KiB
Text
# GOD CRM Production Nginx Configuration
|
|
# ADR-064 Phase 3, Task 11
|
|
#
|
|
# Install: ln -sf /root/workspace/business-crm/deploy/nginx/godcrm.conf /etc/nginx/sites-enabled/godcrm.conf
|
|
# Test: nginx -t
|
|
# Reload: systemctl reload nginx
|
|
|
|
# Rate limiting zones (in http context)
|
|
limit_req_zone $binary_remote_addr zone=api:10m rate=100r/m;
|
|
limit_req_zone $binary_remote_addr zone=auth:10m rate=10r/m;
|
|
|
|
# HTTPS server
|
|
server {
|
|
listen 443 ssl http2;
|
|
server_name crm.hltrn.cc;
|
|
|
|
# TLS
|
|
ssl_certificate /etc/letsencrypt/live/crm.hltrn.cc/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/crm.hltrn.cc/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_timeout 10m;
|
|
|
|
# Security headers (supplement Helmet)
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
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;
|
|
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self' wss: https:;" always;
|
|
|
|
# Logging
|
|
access_log /var/log/nginx/crm.hltrn.cc.access.log;
|
|
error_log /var/log/nginx/crm.hltrn.cc.error.log;
|
|
|
|
# Rate limiting for auth endpoints (stricter: 10 req/min)
|
|
location /api/v3/auth/ {
|
|
limit_req zone=auth burst=5 nodelay;
|
|
proxy_pass http://127.0.0.1:5000;
|
|
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;
|
|
}
|
|
|
|
# Health check (no rate limit — used by monitoring)
|
|
location /api/health {
|
|
proxy_pass http://127.0.0.1:5000;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
# FIX #45201: Google OAuth SPA route - exact match for frontend callback page
|
|
location = /auth/google/complete {
|
|
try_files $uri /index.html;
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
|
|
# Google OAuth - proxy all /auth/google/* to backend (callback, connect, etc.)
|
|
location ^~ /auth/google/ {
|
|
proxy_pass http://127.0.0.1:5000;
|
|
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;
|
|
}
|
|
|
|
# API proxy with rate limiting (100 req/min)
|
|
location /api/ {
|
|
limit_req zone=api burst=200 nodelay;
|
|
proxy_pass http://127.0.0.1:5000;
|
|
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 1800s; # 30 min — match Claude CLI timeout (BUG-504 hotfix)
|
|
proxy_send_timeout 1800s; # 30 min — match Claude CLI timeout (BUG-504 hotfix)
|
|
proxy_connect_timeout 30s; # Connection establishment only
|
|
client_max_body_size 50m;
|
|
}
|
|
|
|
# WebSocket support for chat
|
|
location /ws/ {
|
|
proxy_pass http://127.0.0.1:5000;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_read_timeout 86400;
|
|
}
|
|
|
|
# Uploaded files — served by nginx directly
|
|
location /uploads/ {
|
|
alias /var/lib/business-crm-data/uploads/;
|
|
expires 7d;
|
|
add_header Cache-Control "public";
|
|
|
|
# Security: block script execution
|
|
location ~* \.(php|pl|py|sh|cgi)$ {
|
|
deny all;
|
|
}
|
|
}
|
|
|
|
# Static assets with long cache (fingerprinted by Vite)
|
|
location /assets/ {
|
|
root /var/www/business-crm/dist;
|
|
expires 30d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Static frontend — SPA fallback
|
|
location / {
|
|
root /var/www/business-crm/dist;
|
|
try_files $uri $uri/ /index.html;
|
|
expires 1d;
|
|
add_header Cache-Control "public, no-transform";
|
|
}
|
|
}
|
|
|
|
# HTTP redirect to HTTPS
|
|
server {
|
|
listen 80;
|
|
server_name crm.hltrn.cc;
|
|
return 301 https://$server_name$request_uri;
|
|
}
|