I need to redirect the traffic to one backend or another according to the user-agent. Is that the right thing to do ?
server {
listen 80;
server_name my_domain.com;
if ($http_user_agent ~ iPhone ) {
rewrite ^(.*) https://m.domain1.com$1 permanent;
}
if ($http_user_agent ~ Android ) {
rewrite ^(.*) https://m.domain1.com$1 permanent;
}
if ($http_user_agent ~ MSIE ) {
rewrite ^(.*) https://domain2.com$1 permanent;
}
if ($http_user_agent ~ Mozilla ) {
rewrite ^(.*) https://domain2.com$1 permanent;
}
}