Repository navigation
Expand file tree
/
Copy pathnginx.webcodex.example.conf
More file actions
103 lines (89 loc) · 3.55 KB
/
Copy pathnginx.webcodex.example.conf
File metadata and controls
103 lines (89 loc) · 3.55 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 reverse proxy sample for WebCodex.
#
# Copy to /etc/nginx/sites-available/webcodex.example.com.conf, symlink into
# sites-enabled, reload nginx. Replace webcodex.example.com with your domain and
# point ssl_certificate / ssl_certificate_key at your cert (e.g. Let's Encrypt).
#
# Requirements covered here:
# - HTTPS server block (with a plain-HTTP redirect).
# - WebSocket upgrade for GET /api/agents/ws (Upgrade / Connection headers,
# HTTP/1.1 upstream).
# - /openapi.json (GET), /mcp (POST), /api/agents/ws (WebSocket).
# - Reasonable body size / timeout for long runtime tool calls.
# - Forwarded Host / X-Real-IP / X-Forwarded-For / X-Forwarded-Proto.
#
# The upstream webcodex server should be bound to 127.0.0.1:8080
# (WEBCODEX_ADDR=127.0.0.1:8080). WEBCODEX_TOKEN is the application gate; TLS is the
# transport gate. The server is a zero-project-config relay and does not need a
# projects.toml.
upstream webcodex_backend {
server 127.0.0.1:8080;
# WebSocket requires HTTP/1.1 to the upstream (set per-location below).
keepalive 16;
}
# --- Plain HTTP: redirect to HTTPS ---
server {
listen 80;
listen [::]:80;
server_name webcodex.example.com;
# /openapi.json and /mcp are also reachable over HTTP for local checks, but
# in production everything redirects to HTTPS.
return 301 https://$host$request_uri;
}
# --- HTTPS ---
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name webcodex.example.com;
# Replace with your certificate paths (e.g. Let's Encrypt / certbot).
ssl_certificate /etc/letsencrypt/live/webcodex.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/webcodex.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
# Runtime tool calls and job logs can carry sizable payloads.
client_max_body_size 16m;
# Default proxy tuning for the REST / GPT Actions / MCP surface.
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 30s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
# GPT Actions schema (GET only).
location = /openapi.json {
proxy_pass http://webcodex_backend;
}
# MCP JSON-RPC endpoint (POST).
location = /mcp {
proxy_pass http://webcodex_backend;
}
# WebSocket agent transport (preferred). MUST forward Upgrade/Connection
# and keep HTTP/1.1 to the upstream. Long-lived connection: raise timeouts.
location = /api/agents/ws {
proxy_pass http://webcodex_backend;
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_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket sessions are long-lived; do not time them out quickly.
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
# Disable buffering for the upgraded stream.
proxy_buffering off;
}
# Everything else under /api/ (REST, GPT Actions, polling agent fallback,
# audit). POST-only for the GPT Actions surface.
location /api/ {
proxy_pass http://webcodex_backend;
}
# Optional: health/discovery root.
location / {
proxy_pass http://webcodex_backend;
}
}