{"id":231277,"date":"2014-07-28T11:36:02","date_gmt":"2014-07-28T07:36:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=231277"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=231277","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 map \u0432 nginx<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\tmap \u2014 \u043c\u043e\u0449\u043d\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c\u0438.<br \/>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0435\u043d\u043d\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430, \u0438\u0437 \u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442 \u0432\u0441\u0435\u0445 \u0435\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<br \/>  \u041e\u043d\u0430 \u0432 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, GET \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u043a\u0443\u043a\u0438 \u0438 \u043d\u0430\u0431\u043e\u0440\u044b \u0431\u0435\u043a\u0435\u043d\u0434\u043e\u0432 (upstream).<br \/>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0435\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0445\u0430\u0431\u0440\u0430\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 map \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u043c\u0438 \u0438\u0437 location.<br \/>  \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043c\u0435\u0441\u0442\u043e map \u2014 \u0432 \u0431\u043b\u043e\u043a\u0435 http.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 map<\/b><\/p>\n<div class=\"spoiler_text\">\u042d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 (\u043f\u0440\u0430\u0432\u043e\u0439), \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 (\u043b\u0435\u0432\u043e\u0439).<br \/>  \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"nginx\">map $arg_one $var_two {     &quot;one&quot;      &quot;two&quot;; } <\/code><\/pre>\n<p>  \u0412 \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f.<br \/>  \u0412 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 regexp \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<br \/>  \u0414\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 map \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 http.<br \/>  \u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"http:\/\/nginx.org\/ru\/docs\/http\/ngx_http_map_module.html#map\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.  <\/div>\n<\/div>\n<p>  <\/p>\n<h4>\u0417\u0430\u043c\u0435\u043d\u0430 if \u043d\u0430 map<\/h4>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 if \u0432 nginx<\/b><\/p>\n<div class=\"spoiler_text\">if \u0432 nginx \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e.<br \/>  \u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u044d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 <a href=\"http:\/\/wiki.nginx.org\/IfIsEvil\">\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435<\/a>.<br \/>  \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, if \u0432 nginx \u2014 \u044d\u0442\u043e \u0438\u0437 \u0440\u0430\u0437\u0440\u044f\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043c\u0438\u0440 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u0432\u0430\u0441, \u0430 \u043d\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<br \/>  \u041d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 if \u0432 location, nginx \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0443 \u0441\u0435\u0431\u044f \u0434\u0432\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0430, \u0441 if=true \u0438 \u0441 if=false.<br \/>  \u041f\u043b\u044e\u0441, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0440\u044f\u0434\u043e\u043c \u0441 if \u0432 \u043e\u0434\u043d\u043e\u043c location.<br \/>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 if \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0448\u0430\u043d\u0441 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0442\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u043e\u0436\u0438\u0434\u0430\u043b\u0438.<br \/>  \u0414\u043b\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, if \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430 map.  <\/div>\n<\/div>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0437\u0430\u043c\u0435\u043d, \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043a \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443.<\/p>\n<h5>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 \u0432\u0430\u0441, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0442\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f:  <\/p>\n<pre><code class=\"nginx\">if ($arg_one = &quot;one&quot;) {     set $var_two &quot;two&quot;; } <\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e map:  <\/p>\n<pre><code class=\"nginx\">map $arg_one $var_two {     &quot;one&quot;    &quot;two&quot;; } <\/code><\/pre>\n<p>  \u0418 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>$var_two<\/code>.<br \/>  \u0414\u0430\u0436\u0435 \u0432 \u0442\u0430\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0435 \u0443 map \u0435\u0441\u0442\u044c \u043f\u043b\u044e\u0441\u044b:  <\/p>\n<ul>\n<li>\u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0435\u0449\u0451 if, \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432 location, \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0441\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435;<\/li>\n<li>\u0434\u043b\u044f nginx \u044d\u0442\u043e \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f;<\/li>\n<\/ul>\n<p>  <\/p>\n<h5>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/h5>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u044e\u0442 \u043a map, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 if:  <\/p>\n<pre><code class=\"nginx\">if ($arg_one = &quot;one&quot;) {     set $var_two &quot;two&quot;; }  if ($arg_one = &quot;three&quot;) {     set $var_two &quot;four&quot;; } <\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e map:  <\/p>\n<pre><code class=\"nginx\">map $arg_one $var_two {     &quot;one&quot;    &quot;two&quot;;     &quot;three&quot;  &quot;four&quot;; } <\/code><\/pre>\n<p>  \u0423\u0436\u0435 \u0432\u0438\u0434\u0435\u043d \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u043f\u043e \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438.<br \/>  \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 map.<\/p>\n<h5>\u0412\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 if (\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439)<\/h5>\n<p>  \u042f \u043d\u0430\u0445\u043e\u0434\u0438\u043b \u0432 \u0441\u043f\u0438\u0441\u043a\u0430\u0445 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 nginx \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u0441\u0447\u0435\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 if, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439.<br \/>  \u0412\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 if \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0441\u0442\u044b\u043b\u044c \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 if.<br \/>  \u0410 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u0438\u043d map.<br \/>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043d\u043e \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 (\u0433\u0434\u0435 \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f) \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0434\u043d\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0430 \u0446\u0435\u043b\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0432 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u0445.<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 user-agent \u00abHackYou\u00bb, \u0434\u043e\u043b\u0431\u044f\u0449\u0438\u0445\u0441\u044f \u00abPOST\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 &quot;\/admin\/some\/url&quot;.<\/p>\n<p>  \u042d\u0442\u043e, \u0432 \u043f\u0440\u0438\u043d\u0446\u0446\u0438\u043f\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e if:  <\/p>\n<pre><code class=\"nginx\">if ($http_user_agent ~ &quot;HackYou&quot;) {     set $block &quot;A&quot;; }  if ($method = &quot;POST&quot;) {     set $block &quot;${block}B&quot;; }  if ($uri = &quot;\/admin\/some\/url&quot;) {     set $block &quot;${block}C&quot;; }  if ($block = &quot;ABC&quot;) {     return 403; } <\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e map:  <\/p>\n<pre><code class=\"nginx\">map &quot;$http_user_agent:$method:$uri&quot; $block {     &quot;HackYou:POST:\/admin\/some\/url&quot;  &quot;1&quot;; }  if ($block) {     return 403; } <\/code><\/pre>\n<p>  \u0414\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u044f.<br \/>  \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u00ab\u0442\u043e\u0447\u043a\u0430 \u043d\u0435\u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430\u00bb \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 map.<br \/>  \u0415\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0440\u0430\u0441\u0442\u0435\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e user-agent), \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u043c if \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0438\u043b\u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f.<\/p>\n<h4>http \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438<\/h4>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u0441 if \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f:  <\/p>\n<pre><code class=\"nginx\">if ($arg_a = &quot;1&quot;) {     add_header X-one &quot;one&quot;; } add_header X-two &quot;two&quot;; <\/code><\/pre>\n<p>  \u0411\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a (X-one, \u0435\u0441\u043b\u0438 arg_a = true, \u0438 X-two, \u0435\u0441\u043b\u0438 false).<br \/>  \u042d\u0442\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a add_header \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<br \/>  \u0410 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e if \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438, \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u041d\u043e \u0442\u0443\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 map:  <\/p>\n<pre><code class=\"nginx\">map $arg_a $header_one {     &quot;1&quot;    &quot;one&quot;; }  add_header X-one $header_one; add_header X-two &quot;two&quot;; <\/code><\/pre>\n<p>  \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u2014 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e map.<br \/>  \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439, nginx \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a.<br \/>  \u0412\u043e\u043e\u0431\u0449\u0435, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 if \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043c\u043e\u0434\u0443\u043b\u044c headers_more, \u043e\u043d \u043b\u0438\u0448\u0435\u043d \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430 add_header \u043d\u0430\u0441\u0447\u0435\u0442 if.<br \/>  \u041c\u043e\u0434\u0443\u043b\u044c headers_more \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435, \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0433\u0438\u0431\u043a\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u044e\u0431\u044b\u043c\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438, \u043a\u0430\u043a \u043e\u0442\u0432\u0435\u0442\u0430, \u0442\u0430\u043a \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434).<br \/>  \u0412 \u043f\u0430\u0440\u0435 \u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u043e\u0439 map \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u0445\u043e\u0442\u0435\u043b\u043a\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043a\u0443\u043a.<\/p>\n<h4>\u0412\u044b\u0431\u043e\u0440 upstream<\/h4>\n<p>  \u0412 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u0445 \u0442\u0438\u043f\u0430 proxy_pass (fastcgi_pass \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 *_pass), \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c upstream \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0435\u043a\u0435\u043d\u0434\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.<br \/>  \u0422.\u0435. \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:  <\/p>\n<pre><code class=\"nginx\">proxy_pass http:\/\/$php_backend; <\/code><\/pre>\n<p>  \u041e\u0431 \u044d\u0442\u043e\u043c \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 <a href=\"http:\/\/nginx.org\/ru\/docs\/http\/ngx_http_proxy_module.html#proxy_pass\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>:  <\/p>\n<blockquote><p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043c\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u0449\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e resolver\u2019\u0430. <\/p><\/blockquote>\n<p>  \u0412 \u043f\u0430\u0440\u0435 \u0441 map, \u044d\u0442\u043e \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0438.<br \/>  \u0412\u043e\u0442 \u0433\u0440\u0443\u0431\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u0430\u043a\u043e\u0435:<br \/>  \u0415\u0441\u0442\u044c \u043a\u0443\u043a\u0430 userid.<br \/>  \u0415\u0441\u043b\u0438 \u0432 \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 4, \u0442\u043e \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 upstream old_php_backend.<br \/>  \u0415\u0441\u043b\u0438 \u0441 5 \u0434\u043e 9 \u2014 \u043d\u0430 new_php_backend.<br \/>  \u0415\u0441\u043b\u0438 \u043a\u0443\u043a\u0438 \u043d\u0435\u0442, \u0438\u043b\u0438 \u043e\u043d\u0430 \u043f\u0443\u0441\u0442\u0430\u044f, \u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u2014 \u043d\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u043e \u043d\u0430 default_php_backend.<\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e if, rewrite \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 location:  <\/p>\n<pre><code class=\"nginx\">location \/some\/url\/ {     if ($cookie_userid ~ &quot;~^[0-4]&quot;) { rewrite ^(.+)$ \/old\/$1 last; }     if ($cookie_userid ~ &quot;~^[5-9]&quot;) { rewrite ^(.+)$ \/new\/$1 last; }      proxy_pass http:\/\/default_php_backend; }  location \/old\/some\/url\/ {     internal;     rewrite    ^\/old\/(.+)$ $1 break;     proxy_pass http:\/\/old_php_backend; }  location \/new\/some\/url\/ {     internal;     rewrite    ^\/new\/(.+)$ $1 break;     proxy_pass http:\/\/new_php_backend; } <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 map \u0432\u0441\u0435 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442:  <\/p>\n<pre><code class=\"nginx\">map $cookie_userid     $php_backend {     &quot;~^[0-4]&quot;          &quot;old_php_backend&quot;;     &quot;~^[5-9]&quot;          &quot;new_php_backend&quot;;     default        &quot;default_php_backend&quot;; }  location \/some\/url\/ {     proxy_pass http:\/\/$php_backend; } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435, \u0438 \u0441 \u044d\u0442\u0438\u043c \u043d\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<br \/>  \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e default, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u043e, \u043a\u0443\u0434\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441.<br \/>  \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0441 geo\/split_clients.<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 split_clients \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c 1% \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u0435\u043a\u0435\u043d\u0434 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<h4>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u0437 map \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 map<\/h4>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:  <\/p>\n<pre><code class=\"nginx\">map $arg_a $var_a {     &quot;0&quot;    &quot;1&quot;; }  map $var_a $var_b {     &quot;1&quot;    &quot;2&quot;; }  map $var_b $var_c {     &quot;2&quot;    &quot;3&quot;; } <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044c \u043a <code>$var_c<\/code>, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0440\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b map.<br \/>  \u041f\u0440\u0438 GET \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 a=0, <code>$var_c<\/code> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u00ab3\u00bb.<br \/>  nginx \u043f\u0440\u043e\u0436\u0435\u0432\u044b\u0432\u0430\u0435\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0438\u0437 12 map&#8217;\u043e\u0432, \u0434\u0430\u043b\u044c\u0448\u0435 \u044f \u043d\u0435 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b.<br \/>  \u041c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c, \u0440\u0430\u0434\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430, \u0443\u0437\u043d\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043b\u0438\u043d\u043d\u0443 \u0446\u0435\u043f\u043e\u0447\u043a\u0438.<br \/>  \u041e\u0431\u044b\u0447\u043d\u043e \u043c\u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043f\u0430\u0440\u044b map&#8217;\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.<br \/>  \u041c\u043d\u0435 \u044d\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0438 \u043a\u0443\u043a \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 nginx (\u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u2014 \u0434\u0440\u0443\u0433\u043e\u0439).<br \/>  \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 if.<br \/>  \u0412 \u043e\u0434\u043d\u043e\u043c map \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c <code>$var_a<\/code>, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c map \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c <code>$var_b<\/code>, \u0430 \u0442\u0440\u0435\u0442\u0438\u0439 map \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 <code>&quot;$var_a:var_b<\/code>&quot;.<\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435 map \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0435\u0440\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 geo \u0438 split_clients.<br \/>  \u0412 geo \u0438 split_clients \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<br \/>  \u0415\u0441\u043b\u0438 \u0432\u0430\u043c, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 ip, \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, geo+map \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c.<br \/>  \u0410 \u0441\u0432\u044f\u0437\u043a\u0430 split_clients+map \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0433\u0438\u0431\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0434\u043b\u044f 1% \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"nginx\">split_clients &quot;${remote_addr}XXX&quot; $test_percent {     1%                            &quot;1&quot;;     *                             &quot;0&quot;; }  map &quot;$test_percent:$http_user_agent&quot; $test_mobile_users {     &quot;~*^1:.*iphone.*&quot;                  &quot;X-tester: iphone&quot;; }  more_set_input_headers $test_mobile_users; <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 ip \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u043f\u0430\u043b \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 1% \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0438 \u0432 \u0435\u0433\u043e user-agent \u0435\u0441\u0442\u044c \u0441\u043b\u043e\u0432\u043e iphone, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u00abX-tester: iphone\u00bb.<br \/>  \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0430\u0439\u0442\u0430 \u0434\u043b\u044f \u0430\u0439\u0444\u043e\u043d\u043e\u0432.<\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, map \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043c\u0430\u043b\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434.<br \/>  \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 if \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<br \/>  \u0410 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u043c\u0438, \u0442\u0432\u043e\u0440\u0438\u0442 \u0445\u0438\u0442\u0440\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a.<br \/>  \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c, \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0438, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0438\u0442\u0440\u044b\u0435 \u0445\u043e\u0442\u0435\u043b\u043a\u0438. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/231277\/\"> http:\/\/habrahabr.ru\/post\/231277\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\tmap \u2014 \u043c\u043e\u0449\u043d\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c\u0438.<br \/>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0435\u043d\u043d\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430, \u0438\u0437 \u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442 \u0432\u0441\u0435\u0445 \u0435\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<br \/>  \u041e\u043d\u0430 \u0432 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, GET \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u043a\u0443\u043a\u0438 \u0438 \u043d\u0430\u0431\u043e\u0440\u044b \u0431\u0435\u043a\u0435\u043d\u0434\u043e\u0432 (upstream).<br \/>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0435\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0445\u0430\u0431\u0440\u0430\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-231277","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/231277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231277"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/231277\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}