Skip to content

Instantly share code, notes, and snippets.

@FZambia
Created March 22, 2018 20:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FZambia/8627feaeca8dc99a1ca39581a58a21d9 to your computer and use it in GitHub Desktop.
Save FZambia/8627feaeca8dc99a1ca39581a58a21d9 to your computer and use it in GitHub Desktop.
Nginx to proxy Websocket and GRPC traffix on the same port
events {
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl http2;
ssl_certificate cert.pem;
ssl_certificate_key key.pem;
access_log /tmp/access.log main;
error_log /tmp/error.log error;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
location /proto.Centrifuge {
grpc_pass grpc://localhost:8001;
}
location /connection/websocket {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment