forked from nicokaiser/nginx-websocket-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpath-rewriting.conf
30 lines (24 loc) · 893 Bytes
/
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
# WebSocket Proxy with Path Rewriting
#
# Like the other examples, but HTTPS and WSS endpoints are not "/" but
# "/services/myservice/". So something like
# "wss://api.example.com/services/myservice" can be done.
server {
# see simple-wss.conf or simple-ws.conf
location /services/myservice {
# switch off logging
access_log off;
# redirect all HTTP traffic to localhost:8080
proxy_pass http://localhost:8080;
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 /services/myservice/(.*) /$1 break;
proxy_redirect off;
}
}