{"id":325419,"date":"2021-06-24T15:00:21","date_gmt":"2021-06-24T15:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=325419"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=325419","title":{"rendered":"Nginx. \u041e \u0447\u0435\u043c \u043d\u0435 \u043f\u0438\u0448\u0443\u0442 \u0432 \u043a\u043d\u0438\u0433\u0430\u0445"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u0421\u043b\u043e\u043d\u044f\u044f\u0441\u044c \u043f\u043e \u043a\u043d\u0438\u0436\u043d\u043e\u043c\u0443 \u0444\u0435\u0441\u0442\u0438\u0432\u0430\u043b\u044e \u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u044f, \u043a\u0430\u043a \u0434\u043e\u0447\u043a\u0430 \u043f\u044b\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u043d\u0442\u043e\u0432, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0438\u0445 \u0438\u0441\u043a\u0430\u0442\u044c <em>\u0418\u044d\u043d\u0430 \u0421\u0442\u044e\u0430\u0440\u0442\u0430<\/em>, \u043c\u043e\u0439 \u0433\u043b\u0430\u0437 \u0437\u0430\u0446\u0435\u043f\u0438\u043b\u0441\u044f \u0437\u0430 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0431\u0443\u043a\u0432\u044b \u043d\u0430 \u043e\u0431\u043b\u043e\u0436\u043a\u0435: <em>&#171;Nginx&#187;<\/em>.<\/p>\n<p>\u041d\u0430\u0434\u043e \u0436\u0435, \u043d\u0430 \u043f\u043e\u043b\u043a\u0430\u0445 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u0446\u0435\u043b\u044b\u0445 \u0442\u0440\u0438 \u043a\u043d\u0438\u0433\u0438 &#8212; \u043d\u0435 \u043f\u043e\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0438\u0445 \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0435\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435\u043c. \u041f\u0435\u0440\u0432\u0430\u044f, \u0432\u0442\u043e\u0440\u0430\u044f, \u0442\u0440\u0435\u0442\u044c\u044f&#8230; \u041e\u0449\u0443\u0449\u0435\u043d\u0438\u0435, \u0431\u0443\u0434\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u041d\u0443 \u0432\u0440\u043e\u0434\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043c\u043d\u043e\u0433\u043e, \u0442\u0435\u043a\u0441\u0442 \u0441\u0432\u044f\u0437\u043d\u044b\u0439, \u043d\u043e \u043a\u0430\u043a\u043e\u0432\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435? \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 <em>nginx<\/em>, \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 <em>docker, ansible<\/em>. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0442\u043e\u0440\u0443\u044e: <em>wget<\/em>, \u043b\u0438\u043c\u0438\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0430, <em>kubernetes, AWS. <\/em>\u0422\u0440\u0435\u0442\u044c\u044f: <em>GeoIP<\/em>, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u0432\u0435\u0449\u0430\u043d\u0438\u0435, <em>puppet, Azure<\/em>. \u0420\u0435\u0431\u044f\u0442\u0430, \u0430 \u0433\u0434\u0435 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <em>nginx<\/em>? \u041d\u0430 \u043a\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u044b \u0432\u0430\u0448\u0438 \u043a\u043d\u0438\u0433\u0438? \u041d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0430\u0434\u043c\u0438\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0442\u0430\u043a \u0437\u043d\u0430\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u044d\u0442\u043e\u0433\u043e \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430? \u0414\u0430 \u043e\u043d \u0432\u0440\u043e\u0434\u0435 \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0438 \u0441\u0430\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041d\u0430 \u043d\u043e\u0432\u0438\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <em>wget<\/em>? \u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0435\u043c\u0443 \u0437\u043d\u0430\u043d\u0438\u0435 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 <em>ngx_http_degradation_module<\/em> \u0438 \u0442\u0435\u043c \u043f\u0430\u0447\u0435 <em>&#171;\u043e\u0431\u043b\u0430\u043a\u0430&#187;<\/em> \u0432\u0430\u0436\u043d\u0435\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430?   <\/p>\n<p>\u0418\u0442\u0430\u043a. \u041e \u0447\u0435\u043c \u043d\u0435 \u043f\u0438\u0448\u0443\u0442 \u0432 \u043a\u043d\u0438\u0433\u0430\u0445.<br \/>(\u0437\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e <em>NGX_HTTP_<\/em>)<\/p>\n<h3> \u0424\u0430\u0437\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h3>\n<p><em>Nginx<\/em> \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043e\u0434\u0438\u043d\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u044d\u0442\u0430\u043f\u043e\u0432 (\u0444\u0430\u0437). \u041c\u043e\u0434\u0443\u043b\u044c, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044f \u0437\u0430\u043f\u0440\u043e\u0441, \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445. \u042d\u0442\u0438 \u044d\u0442\u0430\u043f\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p><em>\/src\/http\/ngx_http_core_module.h<\/em><\/p>\n<pre><code class=\"nginx\">typedef enum {     NGX_HTTP_POST_READ_PHASE = 0,     NGX_HTTP_SERVER_REWRITE_PHASE,     NGX_HTTP_FIND_CONFIG_PHASE,     NGX_HTTP_REWRITE_PHASE,     NGX_HTTP_POST_REWRITE_PHASE,     NGX_HTTP_PREACCESS_PHASE,     NGX_HTTP_ACCESS_PHASE,     NGX_HTTP_POST_ACCESS_PHASE,     NGX_HTTP_PRECONTENT_PHASE,     NGX_HTTP_CONTENT_PHASE,     NGX_HTTP_LOG_PHASE } ngx_http_phases;<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0444\u0430\u0437\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f. \u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0440\u043e\u0445\u043e\u0434\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435, \u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u0438. \u0421\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0442\u043b\u044f, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f <em>URI<\/em>, \u043d\u043e \u043e\u0431\u043e \u0432\u0441\u0451\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p><em>NGX_HTTP_POST_READ_PHASE<\/em> &#8212; \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0430\u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u0430 \u043d\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0445\u044d\u043d\u0434\u043b\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_realip_module<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0430\u0434\u0440\u0435\u0441 (\u0438 \u043f\u043e\u0440\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430) \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u043e\u043b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u043e\u0439 <em>real_ip_header.<\/em><\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0438 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0444\u0430\u0437\u044b (<em>NGX_HTTP_SERVER_REWRITE_PHASE<\/em>, <em>NGX_HTTP_REWRITE_PHASE<\/em>) \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u044d\u0442\u0430\u043f\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module <\/em>(\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u044b \u043c\u043e\u0434\u0443\u043b\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0437\u0430\u0445). <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, <em>NGX_HTTP_SERVER_REWRITE_PHASE<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 <em>server<\/em>, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a <em>NGX_HTTP_REWRITE_PHASE<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <em>NGX_HTTP_FIND_CONFIG_PHASE. <\/em>\u042d\u0442\u043e\u0442 \u044d\u0442\u0430\u043f (\u0442\u0440\u0435\u0442\u0438\u0439 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430) \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u0432\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438. \u041d\u0430 \u043d\u0435\u043c <em>nginx<\/em> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 (\u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u0442 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e) \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0435\u0440\u0435\u043c <em>nginx<\/em> c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u0444\u0438\u0433:<\/p>\n<pre><code class=\"nginx\">server {   listen       *:80;   server_name  .example.com;   set $test 101;   location \/ {     set $test 201;     set $test 202;     return 200 \"$test\\n\";     set $test 203;   }   set $test 102; }<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK 202<\/code><\/pre>\n<p>\u0438 \u0432\u0438\u0434\u0438\u043c \u0432 \u043b\u043e\u0433\u0435:<\/p>\n<pre><code class=\"bash\">$ grep -E 'http script (set|val)' \/var\/log\/nginx\/error.log | cut -d \" \" -f 6- http script value: \"101\" http script set $test http script value: \"102\" http script set $test http script value: \"201\" http script set $test http script value: \"202\" http script set $test<\/code><\/pre>\n<p>\u0414\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module<\/em> (<em>break<\/em>, <em>if<\/em>, <em>return<\/em>, <em>rewrite<\/em> \u0438 <em>set<\/em>) <strong>\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f<\/strong> <strong>\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e<\/strong>, \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u043e <strong>\u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0430\u0437\u0430\u043c\u0438<\/strong> <em>nginx, <\/em>\u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_SERVER_REWRITE_PHASE<\/em>  \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>$test<\/em> \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b\u043e\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>101, <\/em>\u0437\u0430\u0442\u0435\u043c <em>102 <\/em>(\u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0438\u0436\u0435 \u0431\u043b\u043e\u043a\u0430 <em>location<\/em>)<em>,<\/em> \u0437\u0430\u0442\u0435\u043c \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_REWRITE_PHASE<\/em> \u043e\u043d\u0430 \u0441\u0442\u0430\u043b\u0430 \u0440\u0430\u0432\u043d\u0430 <em>201<\/em> \u0438 <em>202, <\/em>\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u043b\u0430\u0441\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <em>return,<\/em> \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0430\u0437\u0435 \u043f\u0440\u0435\u0440\u0432\u0430\u043b\u0430\u0441\u044c, \u0438 \u0434\u043e &#171;<em>set $test 203;&#187; <\/em>\u0445\u043e\u0434 \u0443\u0436\u0435 \u043d\u0435 \u0434\u043e\u0448\u0435\u043b.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f (\u043f\u044f\u0442\u0430\u044f) \u0444\u0430\u0437\u0430 <em>NGX_HTTP_POST_REWRITE_PHASE<\/em> \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u043e\u0439 \u0438 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438. \u041f\u043e \u0441\u0443\u0442\u0438, \u043d\u0430 \u043d\u0435\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u0444\u0430\u0437\u0435 <em>NGX_HTTP_FIND_CONFIG_PHASE<\/em> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 <em>URI<\/em> \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u043c) \u0446\u0438\u043a\u043b\u0435 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435.<\/p>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e, \u0442\u043e, \u0447\u0442\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <em>rewrite <\/em>\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP<\/em><strong><em>_POST_<\/em><\/strong><em>REWRITE_PHASE<\/em>, \u0430 \u043d\u0435 \u0432 <em>NGX_HTTP_REWRITE_PHASE<\/em>, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <em>rewrite<\/em> \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043d\u0435\u0439.<\/p>\n<pre><code class=\"nginx\">server {   listen       *:80;   server_name  .example.com;      location \/ {     rewrite ^ \/one;     rewrite ^ \/two;     rewrite ^ \/three;   }      location \/one {     return 200 \"one\\n\";   }      location \/two {     return 200 \"two\\n\";   }      location \/three {     return 200 \"three\\n\";   } }<\/code><\/pre>\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK three<\/code><\/pre>\n<pre><code class=\"bash\">$ grep -E '(rewritten|finalize)' \/var\/log\/nginx\/error.log | cut -d \" \" -f 6- rewritten data: \"\/one\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" rewritten data: \"\/two\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" rewritten data: \"\/three\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" http finalize request: 0, \"\/three?\" a:1, c:1<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e \u043c\u043e\u0433\u043b\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 <em>location &#171;\/one&#187; <\/em>\u043d\u0430 \u044d\u0442\u0430\u043f\u0435 &#171;<em>rewrite ^ \/one;&#187;. <\/em>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0436\u0435 \u0434\u0435\u043b\u0435, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f <strong>\u0432\u0441\u0435 \u0442\u0440\u0438<\/strong> <em>rewrite<\/em>, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_POST_REWRITE_PHASE <\/em>(<strong>\u043e\u0434\u0438\u043d \u0440\u0430\u0437<\/strong>) \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0415\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433:<\/p>\n<pre><code class=\"bash\">server {   listen       *:80;   server_name  .example.com;      location \/ {     set $test 101;     rewrite ^ \/one;     set $test 102;     rewrite ^ \/two;     set $test 103;     rewrite ^ \/three;   }      location \/one {     return 200 \"$test\\n\";   }      location \/two {     return 200 \"$test\\n\";   }      location \/three {     return 200 \"$test\\n\";   } }<\/code><\/pre>\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK 103<\/code><\/pre>\n<pre><code class=\"bash\">$ grep -E '(set|val|rewritten|finalize)' \/var\/log\/nginx\/error.log | cut -d \" \" -f 6- kevent set event: 3: ft:-1 fl:0025 http script value: \"101\" http script set $test rewritten data: \"\/one\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" http script value: \"102\" http script set $test rewritten data: \"\/two\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" http script value: \"103\" http script set $test rewritten data: \"\/three\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" http set discard body http finalize request: 0, \"\/three?\" a:1, c:1 <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0434\u0432\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p>1) \u0423\u0436\u0435 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 &#8212; \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module (break, if, return, rewrite <\/em>\u0438 <em>set)<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0440\u0432\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>return <\/em>\u0438\u043b\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0437\u0430\u043c\u0435\u043d\u044b \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>rewrite<\/em> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 <em>&#171;http:\/\/&#187;<\/em>, <em>&#171;https:\/\/&#187;<\/em> \u0438\u043b\u0438 <em>&#171;$scheme&#187;.<\/em><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/p>\n<pre><code class=\"bash\">server {   listen       *:80;   server_name  .example.com;      location \/ {     rewrite ^ \/one;     return 200 \"zero\\n\";   }     location \/one {     return 200 \"one\\n\";   } }<\/code><\/pre>\n<p>\u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 <em>location one<\/em>.<\/p>\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK zero<\/code><\/pre>\n<p>2) \u0412\u0440\u0435\u043c\u044f (\u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u043c\u0435\u0441\u0442\u043e) \u0436\u0438\u0437\u043d\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c <em>location &#8212; <\/em>\u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 <em>set <\/em>\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>$test <\/em>\u0431\u044b\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>&#171;103&#187; <\/em>\u0438 \u043d\u0435 \u0443\u0442\u0440\u0430\u0442\u0438\u043b\u0430 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0432 <em>location &#171;\/three&#187;<\/em>. \u042d\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439, \u043d\u043e \u0438 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044c <em>echo-nginx-module<\/em>, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443 <em>echo<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043a\u043e\u043d\u0442\u0435\u043d\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0412 \u0446\u0435\u043b\u043e\u043c \u044f \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a <em>OpenResty<\/em>, \u0445\u043e\u0442\u044f \u0438 \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u043a \u041c\u0430\u043a\u0441\u0438\u043c \u0414\u0443\u043d\u0438\u043d:<\/p>\n<blockquote>\n<p>\u042f \u0431\u044b \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 &#171;echo&#187;, \u0442\u0430\u043c \u0443 \u0430\u0432\u0442\u043e\u0440\u0430 \u043f\u043e\u0434\u0445\u043e\u0434 &#171;\u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u043e \u0438 \u0445\u043e\u0440\u043e\u0448\u043e&#187;. \u0418\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0441\u0430\u043c\u043e\u0433\u043e nginx&#8217;\u0430 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439.<\/p>\n<\/blockquote>\n<p>\u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043e\u043d \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u0434\u0430 \u0438 \u0441\u0430\u043c\u0430 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u0438\u043a\u0430\u0435\u0442\u0441\u044f \u0441 <a href=\"http:\/\/openresty.org\/download\/agentzh-nginx-tutorials-en.html\" rel=\"noopener noreferrer nofollow\">http:\/\/openresty.org\/download\/agentzh-nginx-tutorials-en.html<\/a><\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 (\u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f): &#171;\u041a\u0430\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043a\u043b\u0438\u0435\u043d\u0442, \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u043a\u043e\u0440\u043d\u044e \u0441\u0430\u0439\u0442\u0430 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c?&#187; \u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e <em>echo-nginx-module<\/em> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <em>NGX_HTTP_CONTENT_PHASE.<\/em><\/p>\n<pre><code class=\"nginx\">server {   listen       *:80;   server_name  .example.com;    location \/ {     set $test one;     echo \"root: $test\";     set $test \"$test two\";     auth_request \/auth;     set $test \"$test three\";   }     location \/auth {     set $test \"$test auth_pre\";     return 200 \"auth: $test\\n\";     set $test \"$test auth_post\";   } }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041e\u0442\u0432\u0435\u0442<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK root: one two three auth_pre<\/code><\/pre>\n<ul>\n<li>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f <strong>\u0432\u0441\u0435<\/strong> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>set<\/em> \u0432 \u043b\u043e\u043a\u0435\u0439\u0448\u0438\u043d\u0435 <em>&#171;\/&#187;;<\/em><\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441 <em>auth_request \/auth;<\/em><\/p>\n<\/li>\n<li>\n<p>\u0412 \u043b\u043e\u043a\u0435\u0439\u0448\u0438\u043d\u0435 <em>&#171;\/auth&#187;<\/em> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0435\u0449\u0451 <strong>\u043e\u0434\u043d\u0430<\/strong> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <em>set<\/em>, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>$test<\/em> \u043d\u0435 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f;<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u043a\u0435\u0439\u0448\u0438\u043d <em>&#171;\/&#187;<\/em> \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442\u0434\u0430\u0447\u0430 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u043e\u0439 <em>echo.<\/em><\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0442\u043e, \u0447\u0442\u043e <em>return 200 &#171;auth: $test\\n&#187;;<\/em> \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430 &#171;\u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f&#187; \u043c\u043e\u0434\u0443\u043b\u0435\u043c <em>ngx_http_auth_request_module<\/em>.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<p><em>NGX_HTTP_PREACCESS_PHASE<\/em> &#8212; \u0437\u0434\u0435\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u043a\u0430\u043a \u0440\u0435\u0434\u043a\u0438\u0439, \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 \u0432\u044b\u0448\u0435, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0440\u044f\u0448\u043d\u0438\u043a\u0430\u043c, <em>ngx_http_degradation_module<\/em>, \u0442\u0430\u043a \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 <em>ngx_http_limit_req_module<\/em> \u0438 <em>ngx_http_limit_conn_module<\/em>. \u0422\u043e \u0435\u0441\u0442\u044c \u044d\u0442\u043e \u044d\u0442\u0430\u043f, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0449\u0451 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u044f\u0441\u043d\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u043d\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0421\u0435\u0434\u044c\u043c\u0430\u044f \u0444\u0430\u0437\u0430 (<em>NGX_HTTP_ACCESS_PHASE<\/em>) &#8212; \u043c\u0435\u0441\u0442\u043e \u0433\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043c\u043e\u0434\u0443\u043b\u0438 <em>ngx_http_access_module<\/em>, <em>ngx_http_auth_basic_module<\/em> \u0438 <em>ngx_http_auth_request_module<\/em>. \u041a\u043b\u0438\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 (\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>satisfy<\/em> \u0432 <em>any<\/em>) \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u043e\u0432, \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_POST_ACCESS_PHASE.<\/em> \u0412 \u044d\u0442\u043e\u0439 \u0444\u0430\u0437\u0435 \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>satisfy<\/em> \u0438 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0432\u0435\u0441\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.<\/p>\n<p>\u041f\u043e\u0447\u0442\u0438 \u0434\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0434\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u043d\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <em>NGX_HTTP_PRECONTENT_PHASE<\/em> \u0435\u0449\u0451 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430(<em>ngx_http_try_files_module<\/em>), \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u043b\u0438 \u043e\u0442\u0437\u0435\u0440\u043a\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c (<em>ngx_http_mirror_module<\/em>) \u0435\u0433\u043e.<\/p>\n<p><em>NGX_HTTP_CONTENT_PHASE <\/em>&#8212; \u044d\u0442\u0430\u043f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0442\u0430, \u0441\u0430\u043c\u0430\u044f &#171;\u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f&#187; \u0444\u0430\u0437\u0430. \u0425\u044d\u043d\u0434\u043b\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u043a\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0438 \u0432\u0435\u0440\u043d\u0435\u0442 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p>\u041d\u0443 \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u0442\u0430\u043f <em>NGX_HTTP_LOG_PHASE<\/em> &#8212; \u0444\u0430\u0437\u0430 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0430 \u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <em>ngx_http_log_module<\/em>. \u042d\u0442\u043e\u0439 \u0444\u0430\u0437\u043e\u0439 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 &#8212; \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c &#171;\u0444\u0430\u0437\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c&#187;. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>ngx_http_map_module<\/em>. \u0414\u0430, \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>map<\/em> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 &#171;\u0444\u043e\u0440\u043c\u0443\u043b\u044b&#187; \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0430\u044f \u043e\u0442 \u0444\u0430\u0437\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0441 \u0444\u0430\u0437\u0430\u043c\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043d\u0438\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043c\u043e\u0434\u0443\u043b\u044f\u043c (\u0430  \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439), \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u043e\u043a \u043e \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0430\u0445 \u0438 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432 <em>nginx <\/em>\u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0430\u0437\u0435.<\/p>\n<p>\u041e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u0434\u044b:<\/p>\n<ul>\n<li>\n<p>NGX_OK &#8212; \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0430\u0437\u0435. <\/p>\n<\/li>\n<li>\n<p>NGX_DECLINED &#8212; \u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0443 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0444\u0430\u0437\u044b. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0445\u044d\u043d\u0434\u043b\u0435\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0444\u0430\u0437\u0435, \u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0430\u0437\u0435. <\/p>\n<\/li>\n<li>\n<p>NGX_AGAIN (\u0434\u043b\u044f \u0444\u0430\u0437 <em>NGX_HTTP_SERVER_REWRITE_PHASE<\/em>, <em>NGX_HTTP_REWRITE_PHASE<\/em>  , <em>NGX_HTTP_PREACCESS_PHASE<\/em>, <em>NGX_HTTP_ACCESS_PHASE<\/em>) \u0438\u043b\u0438 <em>NGX_DONE<\/em> (\u0434\u043b\u044f \u0444\u0430\u0437\u044b <em>NGX_HTTP_CONTENT_PHASE<\/em>) &#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430) \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0430; <\/p>\n<\/li>\n<li>\n<p><em>NGX_ERROR<\/em> \u0438\u043b\u0438 <em>NGX_HTTP_*<\/em> \u2014 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 <em>NGX_ERROR<\/em> \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0440\u0432\u0430\u043d\u043e, \u0438\u043d\u0430\u0447\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d <em>HTTP<\/em> \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432:<\/p>\n<p>1) \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_core_module<\/em> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0445\u044d\u043d\u0434\u043b\u0435\u0440 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 <em>phases<\/em>. \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0430 \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_CONTENT_PHASE<\/em>:<\/p>\n<pre><code class=\"cpp\">static ngx_int_t ngx_http_sample_init(ngx_conf_t *cf) {   ngx_http_handler_pt        *h;   ngx_http_core_main_conf_t  *cmcf;    cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);    h = ngx_array_push(&amp;cmcf-&gt;phases[NGX_HTTP_CONTENT_PHASE].handlers);   if (h == NULL) {     return NGX_ERROR;   }    *h = ngx_http_sample_handler;    return NGX_OK; }<\/code><\/pre>\n<p>2) \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e <em>location<\/em> \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e <em>location<\/em> (\u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0444\u0430\u0437\u044b <em>NGX_HTTP_CONTENT_PHASE<\/em>):<\/p>\n<pre><code class=\"cpp\">static char * ngx_http_sample(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {   ngx_http_core_loc_conf_t  *clcf;    clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);   clcf-&gt;handler = ngx_http_sample_handler;    return NGX_CONF_OK; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0437\u043d\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f &#171;\u0444\u0430\u0437\u043e\u0432\u044b\u0445&#187; \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c &#171;\u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c&#187; \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0441\u0432\u043e\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"bash\">$ grep -E '[ ]+NGX_HTTP_.+_PHASE' ..\/ngx_http_core_module.h |\\ &gt; cut -d ',' -f 1 |\\ &gt; awk '{print $1}' |\\ &gt; xargs -tI %% grep -rF %% . |\\ &gt; cut -d ':' -f 1 \\ &gt; grep -rF NGX_HTTP_POST_READ_PHASE . .\/ngx_http_realip_module.c grep -rF NGX_HTTP_SERVER_REWRITE_PHASE . .\/ngx_http_rewrite_module.c grep -rF NGX_HTTP_FIND_CONFIG_PHASE . grep -rF NGX_HTTP_REWRITE_PHASE . .\/ngx_http_rewrite_module.c grep -rF NGX_HTTP_POST_REWRITE_PHASE . grep -rF NGX_HTTP_PREACCESS_PHASE . .\/ngx_http_limit_req_module.c .\/ngx_http_limit_conn_module.c .\/ngx_http_realip_module.c .\/ngx_http_degradation_module.c grep -rF NGX_HTTP_ACCESS_PHASE . .\/ngx_http_auth_basic_module.c .\/ngx_http_access_module.c .\/ngx_http_auth_request_module.c grep -rF NGX_HTTP_POST_ACCESS_PHASE . grep -rF NGX_HTTP_PRECONTENT_PHASE . .\/ngx_http_mirror_module.c .\/ngx_http_try_files_module.c grep -rF NGX_HTTP_CONTENT_PHASE . .\/ngx_http_random_index_module.c .\/ngx_http_static_module.c .\/ngx_http_dav_module.c .\/ngx_http_gzip_static_module.c .\/ngx_http_index_module.c .\/ngx_http_autoindex_module.c grep -rF NGX_HTTP_LOG_PHASE . .\/ngx_http_log_module.c<\/code><\/pre>\n<pre><code class=\"bash\">$ grep -rF 'clcf-&gt;handler = ' . |\\ &gt; cut -d ':' -f 1 \\ &gt; .\/ngx_http_uwsgi_module.c .\/ngx_http_uwsgi_module.c .\/ngx_http_memcached_module.c .\/ngx_http_grpc_module.c .\/ngx_http_grpc_module.c .\/ngx_http_mp4_module.c .\/ngx_http_fastcgi_module.c .\/ngx_http_fastcgi_module.c .\/ngx_http_flv_module.c .\/ngx_http_scgi_module.c .\/ngx_http_scgi_module.c .\/ngx_http_stub_status_module.c .\/ngx_http_empty_gif_module.c .\/ngx_http_proxy_module.c .\/ngx_http_proxy_module.c .\/perl\/ngx_http_perl_module.c<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451. \u0422\u043e\u0447\u043d\u0435\u0435 \u0435\u0449\u0451 \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435.<br \/>\u0421\u043f\u0430\u0441\u0438\u0431\u043e!<\/p>\n<p><em>\u0418\u0433\u043e\u0440\u044e \u0421\u044b\u0441\u043e\u0435\u0432\u0443<br \/>\u041c\u0430\u043a\u0441\u0438\u043c\u0443 \u0414\u0443\u043d\u0438\u043d\u0443<br \/>\u0412\u0430\u043b\u0435\u043d\u0442\u0438\u043d\u0443 \u0411\u0430\u0440\u0442\u0435\u043d\u0435\u0432\u0443<br \/><\/em>\u0438 \u0432\u0441\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 <em>Nginx<\/em> \u0437\u0430 \u0438\u0437\u0443\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442<\/p>\n<p><em>\u0420\u043e\u043c\u0430\u043d\u0443 \u0410\u0440\u0443\u0442\u044e\u043d\u044f\u043d\u0443<br \/>\u0412\u0430\u043b\u0435\u0440\u0438\u044e \u0425\u043e\u043b\u043e\u0434\u043a\u043e\u0432\u0443<\/em> (\u043a\u043d\u0438\u0433\u0430 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0430\u0441\u044c \ud83d\ude42 )<br \/>\u0437\u0430 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u0441\u0442\u0430\u0442\u044c\u0438<\/p>\n<p><em>\u0418\u0447\u0443\u043d\u044c \u0427\u0436\u0430\u043d\u0443<\/em> \u0437\u0430 \u0441\u043f\u043e\u0440\u043d\u044b\u0435, \u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/p>\n<p><em>\u042d\u0432\u0430\u043d\u0443 \u041c\u0438\u043b\u043b\u0435\u0440\u0443<\/em> \u0437\u0430 &#171;\u0441\u0443\u0448\u0435\u043d\u044b\u0439 \u0443\u043a\u0440\u043e\u043f&#187;<\/p>\n<\/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=\"https:\/\/habr.com\/ru\/post\/561758\/\"> https:\/\/habr.com\/ru\/post\/561758\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u0421\u043b\u043e\u043d\u044f\u044f\u0441\u044c \u043f\u043e \u043a\u043d\u0438\u0436\u043d\u043e\u043c\u0443 \u0444\u0435\u0441\u0442\u0438\u0432\u0430\u043b\u044e \u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u044f, \u043a\u0430\u043a \u0434\u043e\u0447\u043a\u0430 \u043f\u044b\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u043d\u0442\u043e\u0432, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0438\u0445 \u0438\u0441\u043a\u0430\u0442\u044c <em>\u0418\u044d\u043d\u0430 \u0421\u0442\u044e\u0430\u0440\u0442\u0430<\/em>, \u043c\u043e\u0439 \u0433\u043b\u0430\u0437 \u0437\u0430\u0446\u0435\u043f\u0438\u043b\u0441\u044f \u0437\u0430 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0431\u0443\u043a\u0432\u044b \u043d\u0430 \u043e\u0431\u043b\u043e\u0436\u043a\u0435: <em>&#171;Nginx&#187;<\/em>.<\/p>\n<p>\u041d\u0430\u0434\u043e \u0436\u0435, \u043d\u0430 \u043f\u043e\u043b\u043a\u0430\u0445 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u0446\u0435\u043b\u044b\u0445 \u0442\u0440\u0438 \u043a\u043d\u0438\u0433\u0438 &#8212; \u043d\u0435 \u043f\u043e\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0438\u0445 \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0435\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435\u043c. \u041f\u0435\u0440\u0432\u0430\u044f, \u0432\u0442\u043e\u0440\u0430\u044f, \u0442\u0440\u0435\u0442\u044c\u044f&#8230; \u041e\u0449\u0443\u0449\u0435\u043d\u0438\u0435, \u0431\u0443\u0434\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u041d\u0443 \u0432\u0440\u043e\u0434\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043c\u043d\u043e\u0433\u043e, \u0442\u0435\u043a\u0441\u0442 \u0441\u0432\u044f\u0437\u043d\u044b\u0439, \u043d\u043e \u043a\u0430\u043a\u043e\u0432\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435? \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 <em>nginx<\/em>, \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 <em>docker, ansible<\/em>. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0442\u043e\u0440\u0443\u044e: <em>wget<\/em>, \u043b\u0438\u043c\u0438\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0430, <em>kubernetes, AWS. <\/em>\u0422\u0440\u0435\u0442\u044c\u044f: <em>GeoIP<\/em>, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u0432\u0435\u0449\u0430\u043d\u0438\u0435, <em>puppet, Azure<\/em>. \u0420\u0435\u0431\u044f\u0442\u0430, \u0430 \u0433\u0434\u0435 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <em>nginx<\/em>? \u041d\u0430 \u043a\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u044b \u0432\u0430\u0448\u0438 \u043a\u043d\u0438\u0433\u0438? \u041d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0430\u0434\u043c\u0438\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0442\u0430\u043a \u0437\u043d\u0430\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u044d\u0442\u043e\u0433\u043e \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430? \u0414\u0430 \u043e\u043d \u0432\u0440\u043e\u0434\u0435 \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0438 \u0441\u0430\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041d\u0430 \u043d\u043e\u0432\u0438\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <em>wget<\/em>? \u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0435\u043c\u0443 \u0437\u043d\u0430\u043d\u0438\u0435 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 <em>ngx_http_degradation_module<\/em> \u0438 \u0442\u0435\u043c \u043f\u0430\u0447\u0435 <em>&#171;\u043e\u0431\u043b\u0430\u043a\u0430&#187;<\/em> \u0432\u0430\u0436\u043d\u0435\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430?   <\/p>\n<p>\u0418\u0442\u0430\u043a. \u041e \u0447\u0435\u043c \u043d\u0435 \u043f\u0438\u0448\u0443\u0442 \u0432 \u043a\u043d\u0438\u0433\u0430\u0445.<br \/>(\u0437\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e <em>NGX_HTTP_<\/em>)<\/p>\n<h3> \u0424\u0430\u0437\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h3>\n<p><em>Nginx<\/em> \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043e\u0434\u0438\u043d\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u044d\u0442\u0430\u043f\u043e\u0432 (\u0444\u0430\u0437). \u041c\u043e\u0434\u0443\u043b\u044c, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044f \u0437\u0430\u043f\u0440\u043e\u0441, \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445. \u042d\u0442\u0438 \u044d\u0442\u0430\u043f\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p><em>\/src\/http\/ngx_http_core_module.h<\/em><\/p>\n<pre><code class=\"nginx\">typedef enum {     NGX_HTTP_POST_READ_PHASE = 0,     NGX_HTTP_SERVER_REWRITE_PHASE,     NGX_HTTP_FIND_CONFIG_PHASE,     NGX_HTTP_REWRITE_PHASE,     NGX_HTTP_POST_REWRITE_PHASE,     NGX_HTTP_PREACCESS_PHASE,     NGX_HTTP_ACCESS_PHASE,     NGX_HTTP_POST_ACCESS_PHASE,     NGX_HTTP_PRECONTENT_PHASE,     NGX_HTTP_CONTENT_PHASE,     NGX_HTTP_LOG_PHASE } ngx_http_phases;<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0444\u0430\u0437\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f. \u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0440\u043e\u0445\u043e\u0434\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435, \u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u0438. \u0421\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0442\u043b\u044f, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f <em>URI<\/em>, \u043d\u043e \u043e\u0431\u043e \u0432\u0441\u0451\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p><em>NGX_HTTP_POST_READ_PHASE<\/em> &#8212; \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0430\u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u0430 \u043d\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0445\u044d\u043d\u0434\u043b\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_realip_module<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0430\u0434\u0440\u0435\u0441 (\u0438 \u043f\u043e\u0440\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430) \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u043e\u043b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u043e\u0439 <em>real_ip_header.<\/em><\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0438 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0444\u0430\u0437\u044b (<em>NGX_HTTP_SERVER_REWRITE_PHASE<\/em>, <em>NGX_HTTP_REWRITE_PHASE<\/em>) \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u044d\u0442\u0430\u043f\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module <\/em>(\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u044b \u043c\u043e\u0434\u0443\u043b\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0437\u0430\u0445). <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, <em>NGX_HTTP_SERVER_REWRITE_PHASE<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 <em>server<\/em>, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a <em>NGX_HTTP_REWRITE_PHASE<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <em>NGX_HTTP_FIND_CONFIG_PHASE. <\/em>\u042d\u0442\u043e\u0442 \u044d\u0442\u0430\u043f (\u0442\u0440\u0435\u0442\u0438\u0439 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430) \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u0432\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438. \u041d\u0430 \u043d\u0435\u043c <em>nginx<\/em> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 (\u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u0442 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e) \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0435\u0440\u0435\u043c <em>nginx<\/em> c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u0444\u0438\u0433:<\/p>\n<pre><code class=\"nginx\">server {   listen       *:80;   server_name  .example.com;   set $test 101;   location \/ {     set $test 201;     set $test 202;     return 200 \"$test\\n\";     set $test 203;   }   set $test 102; }<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK 202<\/code><\/pre>\n<p>\u0438 \u0432\u0438\u0434\u0438\u043c \u0432 \u043b\u043e\u0433\u0435:<\/p>\n<pre><code class=\"bash\">$ grep -E 'http script (set|val)' \/var\/log\/nginx\/error.log | cut -d \" \" -f 6- http script value: \"101\" http script set $test http script value: \"102\" http script set $test http script value: \"201\" http script set $test http script value: \"202\" http script set $test<\/code><\/pre>\n<p>\u0414\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module<\/em> (<em>break<\/em>, <em>if<\/em>, <em>return<\/em>, <em>rewrite<\/em> \u0438 <em>set<\/em>) <strong>\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f<\/strong> <strong>\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e<\/strong>, \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u043e <strong>\u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0430\u0437\u0430\u043c\u0438<\/strong> <em>nginx, <\/em>\u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_SERVER_REWRITE_PHASE<\/em>  \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>$test<\/em> \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b\u043e\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>101, <\/em>\u0437\u0430\u0442\u0435\u043c <em>102 <\/em>(\u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0438\u0436\u0435 \u0431\u043b\u043e\u043a\u0430 <em>location<\/em>)<em>,<\/em> \u0437\u0430\u0442\u0435\u043c \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_REWRITE_PHASE<\/em> \u043e\u043d\u0430 \u0441\u0442\u0430\u043b\u0430 \u0440\u0430\u0432\u043d\u0430 <em>201<\/em> \u0438 <em>202, <\/em>\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u043b\u0430\u0441\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <em>return,<\/em> \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0430\u0437\u0435 \u043f\u0440\u0435\u0440\u0432\u0430\u043b\u0430\u0441\u044c, \u0438 \u0434\u043e &#171;<em>set $test 203;&#187; <\/em>\u0445\u043e\u0434 \u0443\u0436\u0435 \u043d\u0435 \u0434\u043e\u0448\u0435\u043b.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f (\u043f\u044f\u0442\u0430\u044f) \u0444\u0430\u0437\u0430 <em>NGX_HTTP_POST_REWRITE_PHASE<\/em> \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u043e\u0439 \u0438 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438. \u041f\u043e \u0441\u0443\u0442\u0438, \u043d\u0430 \u043d\u0435\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u0444\u0430\u0437\u0435 <em>NGX_HTTP_FIND_CONFIG_PHASE<\/em> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 <em>URI<\/em> \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u043c) \u0446\u0438\u043a\u043b\u0435 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435.<\/p>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e, \u0442\u043e, \u0447\u0442\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <em>rewrite <\/em>\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP<\/em><strong><em>_POST_<\/em><\/strong><em>REWRITE_PHASE<\/em>, \u0430 \u043d\u0435 \u0432 <em>NGX_HTTP_REWRITE_PHASE<\/em>, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <em>rewrite<\/em> \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043d\u0435\u0439.<\/p>\n<pre><code class=\"nginx\">server {   listen       *:80;   server_name  .example.com;      location \/ {     rewrite ^ \/one;     rewrite ^ \/two;     rewrite ^ \/three;   }      location \/one {     return 200 \"one\\n\";   }      location \/two {     return 200 \"two\\n\";   }      location \/three {     return 200 \"three\\n\";   } }<\/code><\/pre>\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK three<\/code><\/pre>\n<pre><code class=\"bash\">$ grep -E '(rewritten|finalize)' \/var\/log\/nginx\/error.log | cut -d \" \" -f 6- rewritten data: \"\/one\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" rewritten data: \"\/two\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" rewritten data: \"\/three\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" http finalize request: 0, \"\/three?\" a:1, c:1<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e \u043c\u043e\u0433\u043b\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 <em>location &#171;\/one&#187; <\/em>\u043d\u0430 \u044d\u0442\u0430\u043f\u0435 &#171;<em>rewrite ^ \/one;&#187;. <\/em>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0436\u0435 \u0434\u0435\u043b\u0435, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f <strong>\u0432\u0441\u0435 \u0442\u0440\u0438<\/strong> <em>rewrite<\/em>, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_POST_REWRITE_PHASE <\/em>(<strong>\u043e\u0434\u0438\u043d \u0440\u0430\u0437<\/strong>) \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0415\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433:<\/p>\n<pre><code class=\"bash\">server {   listen       *:80;   server_name  .example.com;      location \/ {     set $test 101;     rewrite ^ \/one;     set $test 102;     rewrite ^ \/two;     set $test 103;     rewrite ^ \/three;   }      location \/one {     return 200 \"$test\\n\";   }      location \/two {     return 200 \"$test\\n\";   }      location \/three {     return 200 \"$test\\n\";   } }<\/code><\/pre>\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK 103<\/code><\/pre>\n<pre><code class=\"bash\">$ grep -E '(set|val|rewritten|finalize)' \/var\/log\/nginx\/error.log | cut -d \" \" -f 6- kevent set event: 3: ft:-1 fl:0025 http script value: \"101\" http script set $test rewritten data: \"\/one\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" http script value: \"102\" http script set $test rewritten data: \"\/two\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" http script value: \"103\" http script set $test rewritten data: \"\/three\", args: \"\", client: 12.34.56.78, server: example.com, request: \"GET \/ HTTP\/1.1\", host: \"example.com\" http set discard body http finalize request: 0, \"\/three?\" a:1, c:1 <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0434\u0432\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p>1) \u0423\u0436\u0435 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 &#8212; \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module (break, if, return, rewrite <\/em>\u0438 <em>set)<\/em> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0440\u0432\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>return <\/em>\u0438\u043b\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0437\u0430\u043c\u0435\u043d\u044b \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>rewrite<\/em> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 <em>&#171;http:\/\/&#187;<\/em>, <em>&#171;https:\/\/&#187;<\/em> \u0438\u043b\u0438 <em>&#171;$scheme&#187;.<\/em><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/p>\n<pre><code class=\"bash\">server {   listen       *:80;   server_name  .example.com;      location \/ {     rewrite ^ \/one;     return 200 \"zero\\n\";   }     location \/one {     return 200 \"one\\n\";   } }<\/code><\/pre>\n<p>\u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 <em>location one<\/em>.<\/p>\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK zero<\/code><\/pre>\n<p>2) \u0412\u0440\u0435\u043c\u044f (\u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u043c\u0435\u0441\u0442\u043e) \u0436\u0438\u0437\u043d\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c <em>location &#8212; <\/em>\u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 <em>set <\/em>\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>$test <\/em>\u0431\u044b\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>&#171;103&#187; <\/em>\u0438 \u043d\u0435 \u0443\u0442\u0440\u0430\u0442\u0438\u043b\u0430 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0432 <em>location &#171;\/three&#187;<\/em>. \u042d\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439, \u043d\u043e \u0438 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044c <em>echo-nginx-module<\/em>, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443 <em>echo<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043a\u043e\u043d\u0442\u0435\u043d\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0412 \u0446\u0435\u043b\u043e\u043c \u044f \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a <em>OpenResty<\/em>, \u0445\u043e\u0442\u044f \u0438 \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u043a \u041c\u0430\u043a\u0441\u0438\u043c \u0414\u0443\u043d\u0438\u043d:<\/p>\n<blockquote>\n<p>\u042f \u0431\u044b \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 &#171;echo&#187;, \u0442\u0430\u043c \u0443 \u0430\u0432\u0442\u043e\u0440\u0430 \u043f\u043e\u0434\u0445\u043e\u0434 &#171;\u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u043e \u0438 \u0445\u043e\u0440\u043e\u0448\u043e&#187;. \u0418\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0441\u0430\u043c\u043e\u0433\u043e nginx&#8217;\u0430 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439.<\/p>\n<\/blockquote>\n<p>\u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043e\u043d \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u0434\u0430 \u0438 \u0441\u0430\u043c\u0430 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u0438\u043a\u0430\u0435\u0442\u0441\u044f \u0441 <a href=\"http:\/\/openresty.org\/download\/agentzh-nginx-tutorials-en.html\" rel=\"noopener noreferrer nofollow\">http:\/\/openresty.org\/download\/agentzh-nginx-tutorials-en.html<\/a><\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 (\u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f): &#171;\u041a\u0430\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043a\u043b\u0438\u0435\u043d\u0442, \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u043a\u043e\u0440\u043d\u044e \u0441\u0430\u0439\u0442\u0430 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c?&#187; \u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e <em>echo-nginx-module<\/em> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <em>NGX_HTTP_CONTENT_PHASE.<\/em><\/p>\n<pre><code class=\"nginx\">server {   listen       *:80;   server_name  .example.com;    location \/ {     set $test one;     echo \"root: $test\";     set $test \"$test two\";     auth_request \/auth;     set $test \"$test three\";   }     location \/auth {     set $test \"$test auth_pre\";     return 200 \"auth: $test\\n\";     set $test \"$test auth_post\";   } }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041e\u0442\u0432\u0435\u0442<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ GET -S example.com GET http:\/\/example.com 200 OK root: one two three auth_pre<\/code><\/pre>\n<ul>\n<li>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f <strong>\u0432\u0441\u0435<\/strong> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <em>set<\/em> \u0432 \u043b\u043e\u043a\u0435\u0439\u0448\u0438\u043d\u0435 <em>&#171;\/&#187;;<\/em><\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441 <em>auth_request \/auth;<\/em><\/p>\n<\/li>\n<li>\n<p>\u0412 \u043b\u043e\u043a\u0435\u0439\u0448\u0438\u043d\u0435 <em>&#171;\/auth&#187;<\/em> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0435\u0449\u0451 <strong>\u043e\u0434\u043d\u0430<\/strong> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <em>set<\/em>, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>$test<\/em> \u043d\u0435 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f;<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u043a\u0435\u0439\u0448\u0438\u043d <em>&#171;\/&#187;<\/em> \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442\u0434\u0430\u0447\u0430 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u043e\u0439 <em>echo.<\/em><\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0442\u043e, \u0447\u0442\u043e <em>return 200 &#171;auth: $test\\n&#187;;<\/em> \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430 &#171;\u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f&#187; \u043c\u043e\u0434\u0443\u043b\u0435\u043c <em>ngx_http_auth_request_module<\/em>.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<p><em>NGX_HTTP_PREACCESS_PHASE<\/em> &#8212; \u0437\u0434\u0435\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u043a\u0430\u043a \u0440\u0435\u0434\u043a\u0438\u0439, \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 \u0432\u044b\u0448\u0435, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0440\u044f\u0448\u043d\u0438\u043a\u0430\u043c, <em>ngx_http_degradation_module<\/em>, \u0442\u0430\u043a \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 <em>ngx_http_limit_req_module<\/em> \u0438 <em>n<\/em><\/p>\n<\/p>\n<\/div>\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-325419","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325419","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=325419"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325419\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=325419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=325419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=325419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}