Nginx One Endpoint for Both WebSocket and Normal Requests
- tags: Nginx
- source: https://serverfault.com/a/923254
server {
# ...
location / {
# If "Websocket" is in Upgrade header, then @websocket will take effect,
# otherwise @ will take effect.
try_files /nonexistent @$http_upgrade;
}
location @websocket {
# websocket related stuff
}
location @ {
# web related stuff
}
}