{"id":408759,"date":"2024-06-29T20:21:51","date_gmt":"2024-06-29T20:21:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=408759"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=408759","title":{"rendered":"<span>Nginx. \u0424\u0430\u0437\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. If is Evil?<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0430\u043c\u043e\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0435 \u0437\u043b\u043e \u0432 <em>Nginx<\/em> &#8212; \u044d\u0442\u043e <em>if<\/em> \u0432 <em>location<\/em>. \u041e\u0431 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0430 <a href=\"https:\/\/www.nginx.com\/resources\/wiki\/start\/topics\/depth\/ifisevil\/\" rel=\"noopener noreferrer nofollow\"><em>nginx.com<\/em><\/a>. \u041f\u0440\u043e\u0446\u0438\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u0443\u0441\u043e\u0447\u0435\u043a:<\/p>\n<blockquote>\n<p>The only 100% safe things which may be done inside if in a location context are:<\/p>\n<p>&#8212; return &#8230;; <\/p>\n<p>&#8212; rewrite &#8230; last;<\/p>\n<\/blockquote>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0432\u0438\u0434\u0430<\/p>\n<pre><code class=\"nginx\">location \/ {   if ( $condition ) {     return 418;   }   ... }<\/code><\/pre>\n<p>\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u043e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c <em>&#171;\u0443\u043c\u0435\u043d\u0438\u0438&#187;<\/em>, \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u0442\u043e, \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 100%. \u041d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0432\u0438\u043d\u043e\u0432\u0430\u0442 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u043b\u043e\u043c\u043a\u0435 <em>if<\/em>?<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/habr.com\/ru\/post\/561758\/\" rel=\"noopener noreferrer nofollow\">Nginx. \u041e \u0447\u0435\u043c \u043d\u0435 \u043f\u0438\u0448\u0443\u0442 \u0432 \u043a\u043d\u0438\u0433\u0430\u0445<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/567418\/\" rel=\"noopener noreferrer nofollow\">Nginx. \u0424\u0430\u0437\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/567978\/\" rel=\"noopener noreferrer nofollow\">Nginx. \u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430. \u0412\u0437\u0433\u043b\u044f\u0434 \u0437\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 POST-\u0437\u0430\u043f\u0440\u043e\u0441\u044b:<\/p>\n<pre><code class=\"nginx\">server {     root \/www\/example_com;     listen *:80;     server_name  .example.com;              location \/index.php {         fastcgi_pass   unix:\/var\/run\/php-fpm.sock;         fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;         include        fastcgi_params;     } }<\/code><\/pre>\n<pre><code class=\"bash\">$ cat \/www\/example_com\/index.php &lt;?php var_dump($_REQUEST);<\/code><\/pre>\n<pre><code class=\"bash\">$ curl \\ > -w \"HTTP CODE: %{http_code}\\n\" \\ > -d \"key1=value1\" \\ > -X POST \\ > \"example.com\/index.php\" \\ >  array(1) {   [\"key1\"]=>   string(6) \"value1\" } HTTP CODE: 200 <\/code><\/pre>\n<p>\u0418 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u0438 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0442\u0435\u043b\u043e\u043c (\u043d\u0430\u0432\u0435\u044f\u043d\u043e <a href=\"https:\/\/forum.nginx.org\/read.php?21,292110\" rel=\"noopener noreferrer nofollow\">\u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c<\/a> \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0435). \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0440\u044b\u0432 \u043c\u044b\u0441\u043b\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a\u043e\u043d\u0444\u0438\u0433 \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code class=\"nginx\">server {     root \/www\/example_com;     listen *:80;     server_name  .example.com;              location \/index.php {         fastcgi_pass   unix:\/var\/run\/php-fpm.sock;         fastcgi_param  SCRIPT_FILENAME         $document_root$fastcgi_script_name;         include        fastcgi_params;              if ( $request_body = '' ) {           return 418;         }     } }<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u044b\u0441\u043b\u044c \u044d\u0442\u0430 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u0430, \u0438 \u0432 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 (\u043a\u0430\u043a \u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0442\u0435\u043b\u043e\u043c \u0442\u0430\u043a \u0438 \u0431\u0435\u0437) \u043f\u043e\u043b\u0443\u0447\u0438\u043c <em>418-\u0439<\/em> \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"bash\">$ curl \\ > -w \"HTTP CODE: %{http_code}\\n\" \\ > -X POST \\ > \"example.com\/index.php\" \\ >  HTTP CODE: 418<\/code><\/pre>\n<pre><code class=\"bash\">$ curl \\ > -w \"HTTP CODE: %{http_code}\\n\" \\ > -d \"key1=value1\" \\ > -X POST \\ > \"example.com\/index.php\" \\ >  HTTP CODE: 418<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0444\u0430\u0437\u044b \u0432 Nginx<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">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<\/div>\n<\/details>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>$request_body<\/em>,  \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 <\/p>\n<blockquote>\n<p>\u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 <em>location\u2019\u0430\u0445<\/em>, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u043c\u0438\u00a0<em>proxy_pass<\/em>,\u00a0<em>fastcgi_pass<\/em>,\u00a0<em>uwsgi_pass<\/em>\u00a0\u0438\u00a0<em>scgi_pass<\/em>, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u043b\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e \u0432\u00a0\u0431\u0443\u0444\u0435\u0440 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.  <\/p>\n<\/blockquote>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_CONTENT_PHASE<\/em>, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a, \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <em>if<\/em> \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module<\/em>\u00a0\u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_REWRITE_PHASE<\/em>, \u0442\u043e \u0435\u0441\u0442\u044c, \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>$request_body<\/em> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e \u043f\u0443\u0441\u0442 <em>body<\/em> \u0438\u043b\u0438 \u043d\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u043b\u044e\u0431\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 <em>&#171;418 I&#8217;m a teapot&#187;.<\/em><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0445\u043e\u0442\u044c \u043c\u044b \u0438 \u043f\u043e\u043b\u043e\u043c\u0430\u043b\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, <em>if<\/em> \u0432 <em>location <\/em>\u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043f\u0440\u0438\u0447\u0435\u043c. \u0412\u0441\u0435\u043c\u0443 <em>&#171;\u0432\u0438\u043d\u043e\u0439&#187;<\/em> \u043b\u0438\u0448\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0444\u0430\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/570996\/\"> https:\/\/habr.com\/ru\/articles\/570996\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0430\u043c\u043e\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0435 \u0437\u043b\u043e \u0432 <em>Nginx<\/em> &#8212; \u044d\u0442\u043e <em>if<\/em> \u0432 <em>location<\/em>. \u041e\u0431 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0430 <a href=\"https:\/\/www.nginx.com\/resources\/wiki\/start\/topics\/depth\/ifisevil\/\" rel=\"noopener noreferrer nofollow\"><em>nginx.com<\/em><\/a>. \u041f\u0440\u043e\u0446\u0438\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u0443\u0441\u043e\u0447\u0435\u043a:<\/p>\n<blockquote>\n<p>The only 100% safe things which may be done inside if in a location context are:<\/p>\n<p>&#8212; return &#8230;; <\/p>\n<p>&#8212; rewrite &#8230; last;<\/p>\n<\/blockquote>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0432\u0438\u0434\u0430<\/p>\n<pre><code class=\"nginx\">location \/ {   if ( $condition ) {     return 418;   }   ... }<\/code><\/pre>\n<p>\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u043e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c <em>&#171;\u0443\u043c\u0435\u043d\u0438\u0438&#187;<\/em>, \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u0442\u043e, \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 100%. \u041d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0432\u0438\u043d\u043e\u0432\u0430\u0442 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u043b\u043e\u043c\u043a\u0435 <em>if<\/em>?<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/habr.com\/ru\/post\/561758\/\" rel=\"noopener noreferrer nofollow\">Nginx. \u041e \u0447\u0435\u043c \u043d\u0435 \u043f\u0438\u0448\u0443\u0442 \u0432 \u043a\u043d\u0438\u0433\u0430\u0445<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/567418\/\" rel=\"noopener noreferrer nofollow\">Nginx. \u0424\u0430\u0437\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/567978\/\" rel=\"noopener noreferrer nofollow\">Nginx. \u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430. \u0412\u0437\u0433\u043b\u044f\u0434 \u0437\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 POST-\u0437\u0430\u043f\u0440\u043e\u0441\u044b:<\/p>\n<pre><code class=\"nginx\">server {     root \/www\/example_com;     listen *:80;     server_name  .example.com;              location \/index.php {         fastcgi_pass   unix:\/var\/run\/php-fpm.sock;         fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;         include        fastcgi_params;     } }<\/code><\/pre>\n<pre><code class=\"bash\">$ cat \/www\/example_com\/index.php &lt;?php var_dump($_REQUEST);<\/code><\/pre>\n<pre><code class=\"bash\">$ curl \\ > -w \"HTTP CODE: %{http_code}\\n\" \\ > -d \"key1=value1\" \\ > -X POST \\ > \"example.com\/index.php\" \\ >  array(1) {   [\"key1\"]=>   string(6) \"value1\" } HTTP CODE: 200 <\/code><\/pre>\n<p>\u0418 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u0438 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0442\u0435\u043b\u043e\u043c (\u043d\u0430\u0432\u0435\u044f\u043d\u043e <a href=\"https:\/\/forum.nginx.org\/read.php?21,292110\" rel=\"noopener noreferrer nofollow\">\u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c<\/a> \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0435). \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0440\u044b\u0432 \u043c\u044b\u0441\u043b\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a\u043e\u043d\u0444\u0438\u0433 \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code class=\"nginx\">server {     root \/www\/example_com;     listen *:80;     server_name  .example.com;              location \/index.php {         fastcgi_pass   unix:\/var\/run\/php-fpm.sock;         fastcgi_param  SCRIPT_FILENAME         $document_root$fastcgi_script_name;         include        fastcgi_params;              if ( $request_body = '' ) {           return 418;         }     } }<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u044b\u0441\u043b\u044c \u044d\u0442\u0430 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u0430, \u0438 \u0432 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 (\u043a\u0430\u043a \u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0442\u0435\u043b\u043e\u043c \u0442\u0430\u043a \u0438 \u0431\u0435\u0437) \u043f\u043e\u043b\u0443\u0447\u0438\u043c <em>418-\u0439<\/em> \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"bash\">$ curl \\ > -w \"HTTP CODE: %{http_code}\\n\" \\ > -X POST \\ > \"example.com\/index.php\" \\ >  HTTP CODE: 418<\/code><\/pre>\n<pre><code class=\"bash\">$ curl \\ > -w \"HTTP CODE: %{http_code}\\n\" \\ > -d \"key1=value1\" \\ > -X POST \\ > \"example.com\/index.php\" \\ >  HTTP CODE: 418<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0444\u0430\u0437\u044b \u0432 Nginx<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">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<\/div>\n<\/details>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>$request_body<\/em>,  \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 <\/p>\n<blockquote>\n<p>\u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 <em>location\u2019\u0430\u0445<\/em>, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u043c\u0438\u00a0<em>proxy_pass<\/em>,\u00a0<em>fastcgi_pass<\/em>,\u00a0<em>uwsgi_pass<\/em>\u00a0\u0438\u00a0<em>scgi_pass<\/em>, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u043b\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e \u0432\u00a0\u0431\u0443\u0444\u0435\u0440 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.  <\/p>\n<\/blockquote>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_CONTENT_PHASE<\/em>, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a, \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <em>if<\/em> \u043c\u043e\u0434\u0443\u043b\u044f <em>ngx_http_rewrite_module<\/em>\u00a0\u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0437\u0435 <em>NGX_HTTP_REWRITE_PHASE<\/em>, \u0442\u043e \u0435\u0441\u0442\u044c, \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>$request_body<\/em> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e \u043f\u0443\u0441\u0442 <em>body<\/em> \u0438\u043b\u0438 \u043d\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u043b\u044e\u0431\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 <em>&#171;418 I&#8217;m a teapot&#187;.<\/em><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0445\u043e\u0442\u044c \u043c\u044b \u0438 \u043f\u043e\u043b\u043e\u043c\u0430\u043b\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, <em>if<\/em> \u0432 <em>location <\/em>\u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043f\u0440\u0438\u0447\u0435\u043c. \u0412\u0441\u0435\u043c\u0443 <em>&#171;\u0432\u0438\u043d\u043e\u0439&#187;<\/em> \u043b\u0438\u0448\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0444\u0430\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/570996\/\"> https:\/\/habr.com\/ru\/articles\/570996\/<\/a><br \/><\/br><\/br><\/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-408759","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/408759","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=408759"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/408759\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=408759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=408759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=408759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}