/
wss-proxy-path-rewriting.conf
38 lines (30 loc) · 1.1 KB
/
wss-proxy-path-rewriting.conf
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
# WebSocket Proxy with Path Rewriting
upstream websocket {
server 127.0.0.1:8010;
}
server {
listen 8020 ssl;
# host name to respond to
server_name 127.0.0.1;
# your SSL configuration
# ssl_certificate /opt/letsencrypt/live/my.domain.com/fullchain.pem;
# ssl_certificate_key /opt/letsencrypt/live/my.domain.com/privkey.pem;
ssl_certificate /etc/nginx/certs/nginx-selfsigned.crt; # Replace with the 2 lines above when using CA Cert
ssl_certificate_key /etc/nginx/certs/nginx-selfsigned.key;
location /api/ws {
# switch off logging
access_log off;
# redirect all HTTP traffic to localhost:8010
proxy_pass http://websocket;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Path rewriting
rewrite /api/ws/(.*) /$1 break;
proxy_redirect off;
}
}