forked from DreamLab-AI/origin-logseq-AR
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathnginx.dev.conf
More file actions
318 lines (265 loc) · 10.9 KB
/
nginx.dev.conf
File metadata and controls
318 lines (265 loc) · 10.9 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# VisionFlow Development Nginx Configuration
# Provides unified entry point on port 3001 for all services
pid /var/run/nginx.pid;
error_log /var/log/nginx/error.log crit;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
charset utf-8;
# Custom MIME types for development
# 'ts' and 'js' are removed as they are often predefined, causing warnings.
types {
text/jsx jsx;
text/tsx tsx;
}
# 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;
client_max_body_size 100M;
# WebSocket upgrade mapping
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Upstream services
upstream rust_backend {
server 127.0.0.1:4000;
keepalive 32;
}
upstream vite_frontend {
server 127.0.0.1:5173;
keepalive 32;
}
# Main server block - Development entry point
server {
listen 3001 default_server;
server_name localhost;
# Security headers for SharedArrayBuffer and cross-origin isolation
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Cross-Origin-Embedder-Policy "require-corp" always;
add_header X-Content-Type-Options "nosniff" always;
# === BACKEND ROUTES ===
# REST API endpoints
location /api/ {
proxy_pass http://rust_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;
# Timeouts for long-running operations
proxy_connect_timeout 60s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
# Disable buffering for SSE/streaming responses
proxy_buffering off;
proxy_cache off;
}
# WebSocket endpoint for graph data
location /wss {
proxy_pass http://rust_backend;
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;
# Long timeout for persistent connections
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
# Disable buffering for real-time data
proxy_buffering off;
tcp_nodelay on;
}
# WebSocket endpoint for speech services
location /ws/speech {
proxy_pass http://rust_backend;
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;
# Long timeout for persistent connections
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
# Disable buffering for real-time data
proxy_buffering off;
tcp_nodelay on;
}
# WebSocket endpoint for MCP relay
location /ws/mcp-relay {
proxy_pass http://rust_backend;
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;
# Long timeout for persistent connections
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
# Disable buffering for real-time data
proxy_buffering off;
tcp_nodelay on;
}
# === SOLID PROTOCOL ENDPOINTS → Rust backend (pod mgmt + LDP proxy to JSS) ===
# Solid WebSocket notifications
location /solid/.notifications {
proxy_pass http://rust_backend/api/solid/.notifications;
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;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Authorization $http_authorization;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_connect_timeout 10s;
proxy_buffering off;
proxy_cache off;
}
# All /solid/* → Rust backend at /api/solid/* (pod management + LDP proxy to JSS)
location /solid/ {
proxy_pass http://rust_backend/api/solid/;
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_set_header X-Forwarded-Host $host;
proxy_set_header Authorization $http_authorization;
proxy_set_header X-Forwarded-URI $request_uri;
proxy_pass_header Accept;
proxy_pass_header Content-Type;
proxy_pass_header Link;
proxy_pass_header Slug;
proxy_pass_header If-Match;
proxy_pass_header If-None-Match;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
proxy_connect_timeout 10s;
client_max_body_size 50m;
}
# User pods shortcut → Rust backend at /api/solid/pods/
location /pods/ {
proxy_pass http://rust_backend/api/solid/pods/;
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_set_header X-Forwarded-Host $host;
proxy_set_header Authorization $http_authorization;
proxy_pass_header Accept;
proxy_pass_header Content-Type;
proxy_pass_header Link;
proxy_pass_header Slug;
client_max_body_size 50m;
}
# === COPYPARTY FILE BROWSER ===
location = /browser-test {
return 200 "COPYPARTY ROUTE WORKS\n";
add_header Content-Type text/plain;
}
location ^~ /browser/ {
rewrite ^/browser/(.*) /$1 break;
proxy_pass http://172.18.0.4:3923/;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# Standard reverse proxy headers
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;
# Disable buffering for better streaming performance
proxy_buffering off;
proxy_request_buffering off;
# Timeouts for long uploads
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
send_timeout 3600s;
# Allow large file uploads
client_max_body_size 0;
}
location = /browser {
return 301 /browser/;
}
# === VITE DEV SERVER ROUTES ===
# WebSocket for Vite HMR (Hot Module Replacement)
location /vite-hmr {
proxy_pass http://vite_frontend; # Pass to the vite_frontend upstream
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;
proxy_read_timeout 3600s; # Keep connection open
}
# Vite special endpoints
location ~ ^/(\.vite|node_modules|@vite|@react-refresh|@id|@fs|src) {
proxy_pass http://vite_frontend;
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;
# Cache control for development
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# Static assets with proper MIME types
location ~* \.(js|jsx|ts|tsx|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
proxy_pass http://vite_frontend;
proxy_http_version 1.1;
proxy_set_header Host $host;
# Development cache headers
add_header Cache-Control "no-cache, must-revalidate";
}
# Root - Frontend application (must be last)
location / {
proxy_pass http://vite_frontend;
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;
# Support for client-side routing
proxy_intercept_errors on;
error_page 404 = @vite_fallback;
}
# Fallback for client-side routing
location @vite_fallback {
# Rewrite the request to the root index.html for the SPA.
# This is the correct way to handle proxy_pass in a named location.
rewrite ^ /index.html break;
proxy_pass http://vite_frontend;
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;
}
# Health check endpoint
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
}