What configuration is needed for nginx (the transition from the if to map)?

There is such code. Want to move from to if map.
location /eset_upd {
 if ($http_user_agent ~ .*BPC.[3].*) {
 rewrite ^(.*) /eset_upd/v3/update.ver break;
}
 if ($http_user_agent ~ .*BPC.[4].*) {
 rewrite ^(.*) /eset_upd/v4/update.ver break;
}
 if ($http_user_agent ~ .*BPC.[5].*) {
 rewrite ^(.*) /eset_upd/v5/update.ver break;
}
 if ($http_user_agent ~ .*BPC.[6].*) {
 rewrite ^(.*) /eset_upd/v6/update.ver break;
}
 if ($http_user_agent ~ .*BPC.[7].*) {
 rewrite ^(.*) /eset_upd/v7/update.ver break;
 }

Need to convert to map. All that I got:

map $http_user_agent $url {
 .*BPC.[3].* /eset_upd/v3/update.ver;
 .*BPC.[4].* /eset_upd/v4/update.ver;
 .*BPC.[5].* /eset_upd/v5/update.ver;
 .*BPC.[6].* /eset_upd/v6/update.ver;
 .*BPC.[7].* /eset_upd/v7/update.ver;
}
location /eset_upd {
 if ($url) {
 rewrite ^(.*) $url break;
}

}
September 26th 19 at 06:50
1 answer
September 26th 19 at 06:52
Solution
Give a map like the following:
map $http_user_agent $url {
 ~.*BPC.[3].* /eset_upd/v3/update.ver;
 ~.*BPC.[4].* /eset_upd/v4/update.ver;
 ~.*BPC.[5].* /eset_upd/v5/update.ver;
 ~.*BPC.[6].* /eset_upd/v6/update.ver;
 ~.*BPC.[7].* /eset_upd/v7/update.ver;
 }
Thank you! - unique_Reichel commented on September 26th 19 at 06:55

Find more questions by tags Nginx