I
I
Igor Gorgul2014-07-29 00:27:04
Nginx
Igor Gorgul, 2014-07-29 00:27:04

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

There is such a code. I want to move from if to 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;
                }

It is necessary to convert this business to map. All 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;
  }

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurph, 2014-07-29
@xXxSPYxXx

Make map look like this:

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;
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question