-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathnginx.conf
More file actions
64 lines (54 loc) · 2.01 KB
/
Copy pathnginx.conf
File metadata and controls
64 lines (54 loc) · 2.01 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
# vodle — nginx configuration for production
#
# Serves the Angular SPA and reverse-proxies Matrix API requests
# to the Synapse homeserver on the internal Docker network.
# Conditionally set Connection header for WebSocket upgrade
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# ---------- SPA routing ----------
# Angular uses hash-based routing (#/route), but also try
# HTML5 pushState routes by falling back to index.html.
location / {
try_files $uri $uri/ /index.html;
}
# ---------- Matrix API reverse proxy ----------
# Forward /_matrix/* requests to the Synapse homeserver.
# This lets the browser talk to Matrix on the same origin,
# avoiding CORS issues.
location /_matrix/ {
proxy_pass http://synapse:8008;
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 for Matrix sync
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# Long-polling timeout for Matrix sync (default 30s + buffer)
proxy_read_timeout 120s;
}
# ---------- Matrix well-known ----------
# Required for Matrix server discovery
location /.well-known/matrix/ {
proxy_pass http://synapse:8008;
proxy_set_header Host $host;
}
# ---------- Static asset caching ----------
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_min_length 1000;
}