user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; server { listen 8001; location /api { # limit_except GET { # auth_basic "NGINX Plus API"; # auth_basic_user_file /path/to/passwd/file; # } api write=on; access_log off; } location = /dashboard.html { root /usr/share/nginx/html; access_log off; } location /swagger-ui { root /usr/share/nginx/html; } } keyval_zone zone=canary:64k state=canary.keyval; keyval abswitch $abswitchvalue zone=canary; upstream backendProduction { zone upstream_backend 64k; server springboot-2:8080 ; } upstream backendTest { zone upstream_backend 64k; server springboot-1:8080 ; } server { listen 8002; if ($abswitchvalue = 0){ set $backend "backendTest"; } if ($abswitchvalue = 1){ set $backend "backendProduction"; } location / { proxy_pass http://$backend; } } }