Complete the code to define the upstream servers for canary deployment.
upstream backend {
server backend-v1.example.com;
server [1];
}The canary deployment uses a new version server, here backend-v2.example.com, alongside the stable version.
Complete the code to split traffic with 90% to stable and 10% to canary.
server {
location / {
proxy_pass http://backend;
[1];
}
}The split_clients directive is used to split traffic by percentage. The correct syntax uses server names without domain extensions.
Fix the error in the canary header condition to route 10% traffic to canary.
map $http_x_canary $upstream_canary {
default backend-v1;
[1] backend-v2;
}The map directive matches the header value. Using "yes" is a common practice to indicate canary traffic.
Fill both blanks to complete the canary routing using the map variable.
server {
location / {
proxy_pass http://[1];
proxy_set_header X-Canary [2];
}
}The proxy_pass uses the mapped upstream variable upstream_canary. The header is set to "yes" to indicate canary traffic.
Fill all three blanks to define a canary deployment with weighted upstream and header control.
upstream backend {
server backend-v1.example.com weight=[1];
server backend-v2.example.com weight=[2];
}
server {
location / {
proxy_pass http://backend;
proxy_set_header X-Canary [3];
}
}The weights define 90% traffic to stable and 10% to canary. The header X-Canary is set to "yes" to mark canary requests.