Repository navigation
Expand file tree
/
Copy pathnginx.conf
More file actions
186 lines (164 loc) · 6.54 KB
/
Copy pathnginx.conf
File metadata and controls
186 lines (164 loc) · 6.54 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# WebSocket upgrade mapping (clean handling for mixed HTTP/WS locations)
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Use Docker's internal DNS for lazy upstream resolution (prevents crash on missing services)
resolver 127.0.0.11 valid=30s ipv6=off;
# Load the default MIME types from the main Nginx configuration.
include /etc/nginx/mime.types;
# Security headers
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
gzip_min_length 1000;
# API Routes MCP — SSE stream (GET /kr-mcp/sse)
location /kr-mcp/sse {
set $kr_mcp_host api-routes;
proxy_pass http://$kr_mcp_host:8003/sse;
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;
# SSE streaming: disable connection close and buffering
proxy_set_header Connection '';
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
chunked_transfer_encoding on;
}
# API Routes MCP — JSON-RPC POST messages
location /kr-mcp/messages/ {
set $kr_mcp_host api-routes;
rewrite ^/kr-mcp/(.*) /$1 break;
proxy_pass http://$kr_mcp_host:8003;
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_read_timeout 30s;
}
# API Routes REST — Kiterunner FastAPI (used by API Discovery frontend)
location /kr-api/ {
set $kr_api_host api-routes;
rewrite ^/kr-api/(.*) /$1 break;
proxy_pass http://$kr_api_host:8004;
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_read_timeout 30s;
proxy_send_timeout 30s;
}
# CLI API proxy (HTTP + WebSocket) — BugTraceAI-CLI FastAPI
# Strips /cli-api/ prefix and forwards to CLI on host.
# ^~ so this prefix BEATS the static `\.(png|…)$` regex below — otherwise proxied
# report assets like /cli-api/api/scans/<id>/files/screenshots/*.png (PoC screenshots)
# get caught by the static handler and 404 (the backend serves them fine).
location ^~ /cli-api/ {
# Resolve only when used, so standalone WEB can start without CLI.
set $cli_api_host bugtrace-cli-api;
rewrite ^/cli-api/(.*)$ /$1 break;
proxy_pass http://$cli_api_host:${CLI_API_PORT};
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;
# WebSocket support (scan event streams)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# Long-running scan connections
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
# BugTraceAI-API proxy (HTTP only — no WebSocket)
# Strips /btai-api/ prefix and forwards over the shared Docker network to
# the API service at the Launcher-selected REST port.
location ^~ /btai-api/ {
set $btai_api_host bugtrace-api;
rewrite ^/btai-api/(.*)$ /$1 break;
proxy_pass http://$btai_api_host:${BTAI_API_PORT};
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_read_timeout 3600s;
proxy_send_timeout 3600s;
}
# WEB Backend API proxy (^~ so proxied binary/report assets aren't shadowed by the static regex)
location ^~ /api/ {
set $backend_host backend:3001;
proxy_pass http://$backend_host;
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;
}
# Socket.IO proxy (WebSocket + polling)
location /socket.io/ {
set $backend_host backend:3001;
proxy_pass http://$backend_host/socket.io/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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;
}
# WebSocket proxy for real-time updates
location /ws/ {
set $backend_host backend:3001;
proxy_pass http://$backend_host/ws/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# Static files - React SPA routing
location / {
try_files $uri $uri/ /index.html;
# Prevent browser from caching index.html (JS/CSS have hashed names)
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
# Documentation subdirectories
location /devinfo/ {
try_files $uri $uri/ =404;
}
location /userinfo/ {
try_files $uri $uri/ =404;
}
# Static assets caching
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
# Health check
location /health {
set $backend_host backend:3001;
proxy_pass http://$backend_host/health;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
location /health/detailed {
set $backend_host backend:3001;
proxy_pass http://$backend_host/health/detailed;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
}