works eventually, still shaky
This commit is contained in:
43
nginx-lb.conf
Normal file
43
nginx-lb.conf
Normal file
@@ -0,0 +1,43 @@
|
||||
upstream phoenix_backend {
|
||||
# Hash based on WebSocket handshake key for sticky sessions
|
||||
# Note: Each new connection gets a new key, so reconnections may route differently
|
||||
hash $http_sec_websocket_key consistent;
|
||||
|
||||
# Failover configuration: mark server as down after 3 failed attempts within 30s
|
||||
# Server will be retried after 30s
|
||||
server phoenix1:4000 max_fails=1 fail_timeout=30s;
|
||||
server phoenix2:4000 max_fails=1 fail_timeout=30s;
|
||||
server phoenix3:4000 max_fails=1 fail_timeout=30s;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location /socket {
|
||||
proxy_pass http://phoenix_backend;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://phoenix_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user