You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nginx container to load-balance websocket servers in Kubernetes
3
+
4
+
## Getting Started
5
+
This container is designed to be run in a pod in Kubernetes to proxy websocket requests to a socket server.
6
+
You can provide following environment variables to customize it.
7
+
8
+
```
9
+
# set env var to dns name of the socket server
10
+
SOCKET_SERVER=socket-service
11
+
```
12
+
13
+
This is supposed to work with the service exposed via AWS Elastic Loadbalancer. Make sure you [enable proxy protocol in your ELB](http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/enable-proxy-protocol.html).
14
+
15
+
You should run this as a Kubernetes service. Remember to set `sessionAffinity: ClientIP` to both, this nginx and upstream socket service.
16
+
17
+
Example manifest:
18
+
19
+
```
20
+
apiVersion: v1
21
+
kind: Service
22
+
metadata:
23
+
name: nginx-socket
24
+
labels:
25
+
run: nginx-socket
26
+
spec:
27
+
type: NodePort
28
+
ports:
29
+
- port: 80
30
+
protocol: TCP
31
+
nodePort: 31110
32
+
selector:
33
+
run: nginx-socket
34
+
sessionAffinity: ClientIP
35
+
---
36
+
apiVersion: extensions/v1beta1
37
+
kind: Deployment
38
+
metadata:
39
+
name: nginx-socket
40
+
spec:
41
+
replicas: 3
42
+
template:
43
+
metadata:
44
+
labels:
45
+
run: nginx-socket
46
+
spec:
47
+
containers:
48
+
- name: nginx-socket
49
+
image: apsops/kube-nginx-websocket:v0.1
50
+
ports:
51
+
- containerPort: 80
52
+
env:
53
+
- name: SOCKET_SERVER
54
+
value: socket-service
55
+
```
56
+
57
+
## Contributing
58
+
I plan to make this more modular and reliable.
59
+
60
+
Feel free to open issues and pull requests for bug fixes or features.
61
+
62
+
## Licence
63
+
64
+
This project is licensed under the MIT License. Refer [LICENSE](https://github.com/ApsOps/kube-nginx-websocket/blob/master/LICENSE) for details.
0 commit comments