better switch
This commit is contained in:
@@ -1,17 +1,25 @@
|
||||
map $http_upgrade $proxy_connection {
|
||||
default "https_backend";
|
||||
websocket "ws_backend";
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name frontend;
|
||||
listen 80;
|
||||
server_name example.com;
|
||||
|
||||
location = / {
|
||||
proxy_pass http://${PROXY_HOST}:${RPC_PORT};
|
||||
}
|
||||
location / {
|
||||
proxy_pass http://$proxy_connection;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://${PROXY_HOST}:${WS_PORT};
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
upstream rpc_backend {
|
||||
server ${PROXY_HOST}:${RPC_PORT}${RPC_PATH:-/};
|
||||
}
|
||||
|
||||
upstream ws_backend {
|
||||
server ${PROXY_HOST}:${WS_PORT}${WS_PATH:-/};
|
||||
}
|
||||
Reference in New Issue
Block a user