Last active
April 12, 2017 21:25
-
-
Save ZoltonMD/ddc7ac7bf58eb5341f2717cec68e5add to your computer and use it in GitHub Desktop.
Nginx WebSocket proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To turn a connection between a client and server from HTTP/1.1 into WebSocket, | |
# the protocol switch mechanism available in HTTP/1.1 is used. | |
# There is one subtlety however: since the “Upgrade” is a hop-by-hop header, | |
# it is not passed from a client to proxied server. | |
location /websocket { | |
proxy_pass https://url/websocket; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_redirect off; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment