Skip to content

Commit c3a72cd

Browse files
authored
deploy: allow clients to override how they are routed with route_override cookie (#1583)
1 parent 7ba3c23 commit c3a72cd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

deploy/nginx.prod.conf

+10-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ map $http_upgrade $connection_upgrade {
1717
'' close;
1818
}
1919

20+
# this allows us to override the upstream based on a cookie called `route_override`
21+
map $cookie_route_override $upstream_override {
22+
default $split_upstream;
23+
monolith _monolith;
24+
balancer _balancer;
25+
}
26+
2027
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=1000m inactive=600m;
2128

2229
server {
@@ -25,7 +32,7 @@ server {
2532
http2 on;
2633

2734
location / {
28-
proxy_pass http://$split_upstream$request_uri;
35+
proxy_pass http://$upstream_override$request_uri;
2936
proxy_http_version 1.1;
3037
proxy_set_header Upgrade $http_upgrade;
3138
proxy_set_header Connection "upgrade";
@@ -42,5 +49,7 @@ server {
4249
proxy_send_timeout 7d;
4350

4451
proxy_socket_keepalive on;
52+
53+
add_header X-Upstream $upstream_override;
4554
}
4655
}

0 commit comments

Comments
 (0)