Spaces:
Sleeping
Sleeping
Delete nginx
Browse files- nginx/nginx.conf.template +0 -133
- nginx/proxy_common.conf +0 -17
nginx/nginx.conf.template
DELETED
|
@@ -1,133 +0,0 @@
|
|
| 1 |
-
###############################################################################
|
| 2 |
-
# nginx.conf.template
|
| 3 |
-
#
|
| 4 |
-
# Rendered to /tmp/nginx.conf at container startup by entrypoint.sh using
|
| 5 |
-
# envsubst, so it can pick up the dynamic $PORT Hugging Face Spaces assigns.
|
| 6 |
-
#
|
| 7 |
-
# nginx here is a security-hardening reverse proxy in front of n8n:
|
| 8 |
-
# - Adds HSTS / CSP / X-Frame-Options / X-Content-Type-Options / etc.
|
| 9 |
-
# - Rate limits login and webhook endpoints
|
| 10 |
-
# - Hides internal error detail / server tokens
|
| 11 |
-
# - Disables directory listing
|
| 12 |
-
#
|
| 13 |
-
# n8n listens only on 127.0.0.1:${N8N_PORT} — never exposed directly.
|
| 14 |
-
###############################################################################
|
| 15 |
-
|
| 16 |
-
pid /tmp/nginx.pid;
|
| 17 |
-
worker_processes auto;
|
| 18 |
-
error_log /data/logs/nginx-error.log warn;
|
| 19 |
-
|
| 20 |
-
events {
|
| 21 |
-
worker_connections 1024;
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
http {
|
| 25 |
-
include /etc/nginx/mime.types;
|
| 26 |
-
default_type application/octet-stream;
|
| 27 |
-
|
| 28 |
-
# Don't leak nginx version in headers or error pages.
|
| 29 |
-
server_tokens off;
|
| 30 |
-
|
| 31 |
-
client_body_temp_path /tmp/nginx-client-body;
|
| 32 |
-
proxy_temp_path /tmp/nginx-proxy;
|
| 33 |
-
fastcgi_temp_path /tmp/nginx-fastcgi;
|
| 34 |
-
uwsgi_temp_path /tmp/nginx-uwsgi;
|
| 35 |
-
scgi_temp_path /tmp/nginx-scgi;
|
| 36 |
-
|
| 37 |
-
log_format access_json escape=json
|
| 38 |
-
'{"time":"$time_iso8601","remote_addr":"$remote_addr",'
|
| 39 |
-
'"request":"$request","status":$status,'
|
| 40 |
-
'"body_bytes_sent":$body_bytes_sent,'
|
| 41 |
-
'"request_time":$request_time,'
|
| 42 |
-
'"http_referer":"$http_referer","http_user_agent":"$http_user_agent"}';
|
| 43 |
-
|
| 44 |
-
access_log /data/logs/nginx-access.log access_json;
|
| 45 |
-
|
| 46 |
-
sendfile on;
|
| 47 |
-
keepalive_timeout 65;
|
| 48 |
-
client_max_body_size 25m;
|
| 49 |
-
|
| 50 |
-
# Directory listing is disabled by default (autoindex off) — explicit
|
| 51 |
-
# here for clarity/auditability.
|
| 52 |
-
autoindex off;
|
| 53 |
-
|
| 54 |
-
# --- Rate limiting zones -------------------------------------------------
|
| 55 |
-
limit_req_zone $binary_remote_addr zone=general_limit:10m rate=20r/s;
|
| 56 |
-
limit_req_zone $binary_remote_addr zone=login_limit:10m rate=5r/m;
|
| 57 |
-
limit_req_zone $binary_remote_addr zone=webhook_limit:10m rate=30r/s;
|
| 58 |
-
limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
|
| 59 |
-
|
| 60 |
-
upstream n8n_upstream {
|
| 61 |
-
server 127.0.0.1:${N8N_PORT};
|
| 62 |
-
keepalive 32;
|
| 63 |
-
}
|
| 64 |
-
|
| 65 |
-
server {
|
| 66 |
-
listen ${PORT};
|
| 67 |
-
server_name _;
|
| 68 |
-
|
| 69 |
-
limit_conn conn_limit 40;
|
| 70 |
-
|
| 71 |
-
# --- Security headers ------------------------------------------------
|
| 72 |
-
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
| 73 |
-
add_header X-Frame-Options "SAMEORIGIN" always;
|
| 74 |
-
add_header X-Content-Type-Options "nosniff" always;
|
| 75 |
-
add_header X-XSS-Protection "1; mode=block" always;
|
| 76 |
-
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
| 77 |
-
add_header Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=(), usb=(), interest-cohort=()" always;
|
| 78 |
-
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' wss: https:; frame-ancestors 'self'; base-uri 'self'; form-action 'self'" always;
|
| 79 |
-
add_header Cross-Origin-Opener-Policy "same-origin" always;
|
| 80 |
-
add_header Cross-Origin-Resource-Policy "same-origin" always;
|
| 81 |
-
|
| 82 |
-
# Never cache anything containing auth/session data by default.
|
| 83 |
-
add_header Cache-Control "no-store" always;
|
| 84 |
-
|
| 85 |
-
# Hide nginx-generated error pages' detail; proxy them to n8n instead
|
| 86 |
-
# where possible, otherwise show a minimal generic body.
|
| 87 |
-
proxy_intercept_errors off;
|
| 88 |
-
|
| 89 |
-
# Block access to dotfiles / hidden paths (e.g. .env, .git).
|
| 90 |
-
location ~ /\. {
|
| 91 |
-
deny all;
|
| 92 |
-
return 404;
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
# Health/ready/live endpoints proxied straight through, excluded from
|
| 96 |
-
# rate limiting so orchestrators/monitors never get throttled.
|
| 97 |
-
location = /healthz {
|
| 98 |
-
proxy_pass http://n8n_upstream/healthz;
|
| 99 |
-
access_log off;
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
location = /ready {
|
| 103 |
-
proxy_pass http://n8n_upstream/healthz/readiness;
|
| 104 |
-
access_log off;
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
location = /live {
|
| 108 |
-
proxy_pass http://n8n_upstream/healthz;
|
| 109 |
-
access_log off;
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
# Login / auth endpoints get a stricter rate limit to slow brute force.
|
| 113 |
-
location ~ ^/rest/(login|owner) {
|
| 114 |
-
limit_req zone=login_limit burst=5 nodelay;
|
| 115 |
-
proxy_pass http://n8n_upstream;
|
| 116 |
-
include /app/nginx/proxy_common.conf;
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
# Webhook endpoints: higher throughput allowance, still bounded.
|
| 120 |
-
location ~ ^/webhook {
|
| 121 |
-
limit_req zone=webhook_limit burst=50 nodelay;
|
| 122 |
-
proxy_pass http://n8n_upstream;
|
| 123 |
-
include /app/nginx/proxy_common.conf;
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
# Everything else (editor UI, REST API, websockets for push updates).
|
| 127 |
-
location / {
|
| 128 |
-
limit_req zone=general_limit burst=40 nodelay;
|
| 129 |
-
proxy_pass http://n8n_upstream;
|
| 130 |
-
include /app/nginx/proxy_common.conf;
|
| 131 |
-
}
|
| 132 |
-
}
|
| 133 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nginx/proxy_common.conf
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
# Shared proxy settings included by every location block in nginx.conf.
|
| 2 |
-
# Kept in its own file so websocket / header handling stays consistent.
|
| 3 |
-
|
| 4 |
-
proxy_http_version 1.1;
|
| 5 |
-
proxy_set_header Upgrade $http_upgrade;
|
| 6 |
-
proxy_set_header Connection "upgrade";
|
| 7 |
-
proxy_set_header Host $host;
|
| 8 |
-
proxy_set_header X-Real-IP $remote_addr;
|
| 9 |
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 10 |
-
proxy_set_header X-Forwarded-Proto $scheme;
|
| 11 |
-
proxy_set_header X-Forwarded-Host $host;
|
| 12 |
-
|
| 13 |
-
proxy_read_timeout 300s;
|
| 14 |
-
proxy_send_timeout 300s;
|
| 15 |
-
proxy_connect_timeout 10s;
|
| 16 |
-
|
| 17 |
-
proxy_buffering off;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|