-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnginx.collab.conf
More file actions
74 lines (61 loc) · 2.35 KB
/
Copy pathnginx.collab.conf
File metadata and controls
74 lines (61 loc) · 2.35 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
# /etc/nginx/nginx.conf (collab / develop image)
#
# Superset of nginx.conf: in addition to serving the static SPA it reverse-
# proxies the bundled Y.js collab backend (node, listening on 127.0.0.1:1234)
# so collaboration rides the same origin/port as the app. The frontend is built
# with VITE_COLLAB_URL=<scheme>://<host>/collab, so:
# - WebSocket sessions hit /collab/<docId> -> node /<docId>
# - the pre-flight health check hits /health -> node /health
# The collab server is never exposed directly; only port 80 is published.
# njs dynamic module — bundled with the official nginx:alpine image.
# Required for the /raw endpoint that serves decoded UVL content to UVLHub.
load_module modules/ngx_http_js_module.so;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
js_path "/etc/nginx/njs/";
js_import raw from raw.js;
# Bundled collab (Y.js websocket) server.
upstream collab_backend {
server 127.0.0.1:1234;
}
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Decodes a base64 UVL model from ?model= and returns it as plain text
# so that UVLHub can fetch the raw UVL content server-side.
location /raw {
js_content raw.handler;
}
# Collab WebSocket sessions. Trailing slash strips the /collab/ prefix
# so the doc id reaches the Y.js server as its room name (/<docId>).
location /collab/ {
proxy_pass http://collab_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_read_timeout 3600s;
proxy_send_timeout 3600s;
}
# Health probe the frontend pings before opening a session.
location = /health {
proxy_pass http://collab_backend/health;
proxy_set_header Host $host;
}
location / {
try_files $uri /index.html;
}
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
gzip_min_length 1000;
}
}