Running Meteor app with Nginx SSL proxy on Kubernetes
In your NginX config, did you make sure to use the ip_hash
flag to direct websockets to the same server each time? also you need to make sure the websocket Upgrade headers are forwarded:
upstream meteorapp{ ip_hash; server hostname:port}server { # your server stuff here # location / { proxy_pass http://meteorapp; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; 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 X-Forwarded-Proto http; proxy_redirect http:// $scheme://; }}
The easiest way to run your app would be using Nginx based ingress controller instead of Nginx service.
In my opinion the easiest way to deploy ingress controller is with helm:https://docs.helm.sh/using_helm/#installing-helmhttps://kubeapps.com/charts/stable/nginx-ingress
But if you prefer not adding another tool to your stack you can use official installation guide: https://github.com/kubernetes/ingress-nginx/tree/master/deploy.
Example ingress object configuration with web sockets support can be found here: https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/websocket