-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx-advanced.conf
More file actions
103 lines (83 loc) · 2.72 KB
/
nginx-advanced.conf
File metadata and controls
103 lines (83 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# nginx-advanced.conf
# Production-ready Nginx reverse proxy for ClawdBot
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
# Performance
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# Security
server_tokens off;
client_max_body_size 10m;
# Rate limiting zones
limit_req_zone $binary_remote_addr zone=clawdbot_limit:10m rate=10r/s;
limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
# Upstream
upstream clawdbot_backend {
server 127.0.0.1:18789;
keepalive 32;
}
# HTTPS server
server {
listen 443 ssl http2;
server_name clawdbot.company.internal;
# TLS configuration
ssl_certificate /etc/nginx/ssl/clawdbot.crt;
ssl_certificate_key /etc/nginx/ssl/clawdbot.key;
ssl_protocols TLSv1.3 TLSv1.2;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
# Client certificate (mTLS)
ssl_client_certificate /etc/nginx/ssl/ca.crt;
ssl_verify_client on;
ssl_verify_depth 2;
# Security headers
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
# Rate limiting
limit_req zone=clawdbot_limit burst=20 nodelay;
limit_conn conn_limit 10;
# IP whitelist
allow 10.0.0.0/8;
allow 100.0.0.0/8;
deny all;
location / {
proxy_pass http://clawdbot_backend;
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_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
location /health {
access_log off;
proxy_pass http://clawdbot_backend/health;
}
}
# Redirect HTTP to HTTPS
server {
listen 80;
server_name clawdbot.company.internal;
return 301 https://$server_name$request_uri;
}
}