Map client header to upstream in nginx

Sometimes you want to route traffic to different endpoints based on a http header. Avoiding if statements in the nginx config is the most important part here. The example below is based on the user-agent header that is send from the client. Test nginx conf to view traffic flow # create upstreams # android and other non ios device upstream android { server; } # ios based devices upstream ios { server 127.