{"id":311985,"date":"2020-10-25T09:00:08","date_gmt":"2020-10-25T09:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=311985"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=311985","title":{"rendered":"\u041e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a Content-Type: nginx + php-fpm"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">Rocket science \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 php-fpm, \u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 nginx. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0432 PHP \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f HTTP \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430?<\/p>\n<p>  1. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 <i>Accept<\/i>, <i>Host<\/i> \u0438\u043b\u0438 <i>Referer<\/i>?<br \/>  2. \u0417\u043d\u0430\u0435\u0442\u0435? \u0417\u0434\u043e\u0440\u043e\u0432\u043e! \u0410 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <i>Content-Type<\/i>, <i>Content-Length<\/i>?<br \/>  3. \u041d\u0438\u0447\u0435\u043c \u0432\u0430\u0441 \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0442\u044c, \u0430 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <i>X-Forwarded-For<\/i>?<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uw\/sm\/xj\/uwsmxji8b9ddwlydsmtmfo2bske.png\" alt=\"image\"><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h3>\u041a\u0430\u043a \u0432 PHP \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f HTTP \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430?<\/h3>\n<p>  \u0412\u0441\u0451 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e (\u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0441\u0430\u0440\u043a\u0430\u0437\u043c). \u041d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <a href=\"https:\/\/www.php.net\/manual\/ru\/reserved.variables.server.php\" rel=\"nofollow\">$_SERVER<\/a>.   <\/p>\n<blockquote><p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f $_SERVER \u2014 \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u043a \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u043f\u0443\u0442\u0438 \u0438 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u0417\u0430\u043f\u0438\u0441\u0438 \u0432 \u044d\u0442\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c.<br \/>  <b>\u041d\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438<\/b>, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u043b\u044e\u0431\u0443\u044e \u0438\u0437 \u043d\u0438\u0445;<br \/>  \u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435, \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0437\u0434\u0435\u0441\u044c.<br \/>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043c\u043d\u043e\u0433\u0438\u0435 \u044d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 <a href=\"http:\/\/www.faqs.org\/rfcs\/rfc3875.html\" rel=\"nofollow\">\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 CGI\/1.1<\/a>,<br \/>  \u0442\u0430\u043a \u0447\u0442\u043e <b>\u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0438\u0445 \u043d\u0430\u043b\u0438\u0447\u0438\u0435<\/b>.  <\/p><\/blockquote>\n<p>  \u0421\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c \u0437\u0432\u0443\u0447\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u0431\u043d\u0430\u0434\u0435\u0436\u0438\u0432\u0430\u044e\u0449\u0435? \u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0428\u0440\u0451\u0434\u0438\u043d\u0433\u0435\u0440\u0430. \u041d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441. <\/p>\n<pre><code class=\"php\">$_SERVER['HTTP_ACCEPT'] $_SERVER['HTTP_HOST'] $_SERVER['HTTP_REFERER'] <\/code><\/pre>\n<p>  \u041e\u043a, \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u0445\u043e\u0442\u044c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u0440\u043e CONTENT_TYPE (\u043f\u0440\u0430\u0432\u0434\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f <a href=\"https:\/\/www.php.net\/manual\/ru\/reserved.variables.server.php#110763\" rel=\"nofollow\">\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430<\/a> \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f 2013 \u0433\u043e\u0434\u0430), \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438. <\/p>\n<pre><code class=\"php\">$_SERVER['HTTP_CONTENT_TYPE']<\/code><\/pre>\n<p> \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043d\u0435\u0442 \ud83d\ude41<\/p>\n<p>  \u041d\u0443 \u0434\u0430 \u043b\u0430\u0434\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c <a href=\"http:\/\/www.faqs.org\/rfcs\/rfc3875.html\" rel=\"nofollow\">\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e CGI\/1.1<\/a>. <\/p>\n<blockquote><p>4.1.3. CONTENT_TYPE<br \/>   If the request includes a message-body, the CONTENT_TYPE variable is<br \/>   set to the Internet Media Type [6] of the message-body.<\/p>\n<p>  \/\/\u2026<\/p>\n<p>  There is no default value for this variable. If and only if it is<br \/>   unset, then the script MAY attempt to determine the media type from<br \/>   the data received. If the type remains unknown, then the script MAY<br \/>   choose to assume a type of application\/octet-stream or it may reject<br \/>   the request with an error (as described in section 6.3.3).<\/p>\n<p>  \/\/\u2026<\/p>\n<p>  The server MUST set this meta-variable if an HTTP Content-Type field<br \/>   is present in the client request header. If the server receives a<br \/>   request with an attached entity but no Content-Type header field, it<br \/>   MAY attempt to determine the correct content type, otherwise it<br \/>   should omit this meta-variable.  <\/p><\/blockquote>\n<p>  \u041c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441.  <\/p>\n<pre><code class=\"php\">$_SERVER['CONTENT_TYPE'] $_SERVER['CONTENT_LENGTH'] <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a 3-\u043c\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0443, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0432 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.  <\/p>\n<blockquote><p>4.1.18. Protocol-Specific Meta-Variables<\/p>\n<p>  The server SHOULD set meta-variables specific to the protocol and<br \/>   scheme for the request. Interpretation of protocol-specific<br \/>   variables depends on the protocol version in SERVER_PROTOCOL. The<br \/>   server MAY set a meta-variable with the name of the scheme to a<br \/>   non-NULL value if the scheme is not the same as the protocol. The<br \/>   presence of such a variable indicates to a script which scheme is<br \/>   used by the request.<\/p>\n<p>  <b>Meta-variables with names beginning with \u00abHTTP_\u00bb contain values read<br \/>   from the client request header fields, if the protocol used is HTTP.<br \/>   The HTTP header field name is converted to upper case, has all<br \/>   occurrences of &quot;-&quot; replaced with &quot;_&quot; and has \u00abHTTP_\u00bb prepended to<br \/>   give the meta-variable name.<\/b> The header data can be presented as<br \/>   sent by the client, or can be rewritten in ways which do not change<br \/>   its semantics. If multiple header fields with the same field-name<br \/>   are received then the server MUST rewrite them as a single value<br \/>   having the same semantics. Similarly, a header field that spans<br \/>   multiple lines MUST be merged onto a single line. The server MUST,<br \/>   if necessary, change the representation of the data (for example, the<br \/>   character set) to be appropriate for a CGI meta-variable.<\/p>\n<p>  The server is not required to create meta-variables for all the<br \/>   header fields that it receives. <b>In particular, it SHOULD remove any<br \/>   header fields carrying authentication information, such as<br \/>   &#8216;Authorization&#8217;; or that are available to the script in other<br \/>   variables, such as &#8216;Content-Length&#8217; and &#8216;Content-Type&#8217;.<\/b> The server<br \/>   MAY remove header fields that relate solely to client-side<br \/>   communication issues, such as &#8216;Connection&#8217;.  <\/p><\/blockquote>\n<p>  \u0410 \u0432\u043e\u0442 \u0438 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 3-\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441.  <\/p>\n<pre><code class=\"php\">$_SERVER['HTTP_X_FORWARDED_FOR'] <\/code><\/pre>\n<p> \u0422\u0443\u0442 \u0436\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0438\u0442 \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c $_SERVER[&#8216;HTTP_CONTENT_TYPE&#8217;], \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c $_SERVER[&#8216;CONTENT_TYPE&#8217;].<\/p>\n<h3>\u041a\u0430\u043a Content-Type \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $_SERVER[&#8216;CONTENT_TYPE&#8217;]?<\/h3>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u041a\u043e\u043f\u043d\u0451\u043c \u0447\u0443\u0442\u044c \u0433\u043b\u0443\u0431\u0436\u0435, \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 (nginx) \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 php \u043c\u0430\u0441\u0441\u0438\u0432 $_SERVER.<\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u0434\u043d\u044f\u0442\u044c nginx + php-fpm \u0447\u0435\u0440\u0435\u0437 docker-compose  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">docker-compose.yaml<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">version: '3'  services:   nginx_default_fastcgi_params:     image: nginx:1.18     volumes:       - .\/app\/public:\/var\/www\/app\/public:rw       - .\/docker\/nginx_default_fastcgi_params\/app.conf:\/etc\/nginx\/conf.d\/app.conf:rw    php-fpm:     build:       context: docker       dockerfile: .\/php-fpm\/Dockerfile     volumes:       - .\/app:\/var\/www\/app:rw <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c nginx \u043a\u043e\u043d\u0444\u0438\u0433 app.conf  <\/p>\n<pre><code class=\"python\">server {     listen 81;     server_name server1.local;     root \/var\/www\/app\/public;      location \/ {         try_files $uri \/index.php$is_args$args;     }      location ~ ^\/index\\.php {         fastcgi_pass php-fpm:9000;         fastcgi_split_path_info ^(.+\\.php)(\/.*)$;         # file location \/etc\/nginx\/fastcgi_params         include fastcgi_params;          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;     }      error_log \/var\/log\/nginx\/app_error.log;     access_log \/var\/log\/nginx\/app_access.log; } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 <code>include fastcgi_params;<\/code>. \u041e\u043d\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \/etc\/nginx\/fastcgi_params, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a  <\/p>\n<pre><code class=\"python\">fastcgi_param  QUERY_STRING       $query_string; fastcgi_param  REQUEST_METHOD     $request_method; fastcgi_param  CONTENT_TYPE       $content_type; fastcgi_param  CONTENT_LENGTH     $content_length;  fastcgi_param  SCRIPT_NAME        $fastcgi_script_name; fastcgi_param  REQUEST_URI        $request_uri; fastcgi_param  DOCUMENT_URI       $document_uri; fastcgi_param  DOCUMENT_ROOT      $document_root; fastcgi_param  SERVER_PROTOCOL    $server_protocol; fastcgi_param  REQUEST_SCHEME     $scheme; fastcgi_param  HTTPS              $https if_not_empty;  fastcgi_param  GATEWAY_INTERFACE  CGI\/1.1; fastcgi_param  SERVER_SOFTWARE    nginx\/$nginx_version;  fastcgi_param  REMOTE_ADDR        $remote_addr; fastcgi_param  REMOTE_PORT        $remote_port; fastcgi_param  SERVER_ADDR        $server_addr; fastcgi_param  SERVER_PORT        $server_port; fastcgi_param  SERVER_NAME        $server_name;  # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param  REDIRECT_STATUS    200; <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043a\u0430\u043a \u0440\u0430\u0437 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f <code>$_SERVER['CONTENT_TYPE']<\/code>. \u0410 \u0442\u0430\u043a \u0436\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mw\/oy\/m3\/mwoym3e16sf3i9e9cnjb5mdfeiq.png\" alt=\"image\">.<\/p>\n<p>  \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u041a\u0430\u043a \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 HTTP \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 User-Agent \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043e\u0442 nginx \u043a php-fpm?<\/p>\n<p>  \u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f nginx \u0434\u0430\u0451\u0442 <a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_fastcgi_module.html#parameters\" rel=\"nofollow\">\u043e\u0442\u0432\u0435\u0442<\/a>.<\/p>\n<blockquote><p><b>Parameters Passed to a FastCGI Server<\/b><br \/>  <b>HTTP request header fields<\/b> are passed to a FastCGI server as parameters. In applications and scripts running as FastCGI servers, these parameters are <b>usually<\/b> made available as environment variables. For example, the \u201cUser-Agent\u201d header field is passed as the HTTP_USER_AGENT parameter. In addition to HTTP request header fields, it is possible to pass arbitrary parameters using the fastcgi_param directive.  <\/p><\/blockquote>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0437\u0434\u0435\u0441\u044c \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e HTTP \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u0430\u043a HTTP_*. \u041d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0434\u0432\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 Content-Type \u0438 Content-Length, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u042f \u0431\u044b \u043d\u0430\u0437\u0432\u0430\u043b \u044d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u043e \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u0441\u043b\u043e\u0432\u043e usually, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u0434\u0438\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>  1) \u0427\u0442\u043e\u0431\u044b \u0432 php \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 <code>Content-Type\/Content-Length<\/code> \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>$_SERVER['CONTENT_TYPE']\/$_SERVER['CONTENT_LENGTH']<\/code>. \u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 <code>$_SERVER['HTTP_*']<\/code><br \/>  2) \u042f \u043d\u0435 \u0437\u043d\u0430\u044e \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u043f\u043e\u0447\u0435\u043c\u0443 CGI \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 Content-Type\/Content-Length. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u0430 \u0432\u0435\u0441\u043e\u043c\u0430\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430. \u041d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0443\u0447\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \ud83d\ude41<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 <a href=\"https:\/\/stackoverflow.com\/a\/541463\/3178453\" rel=\"nofollow\">stackoverflow<\/a> \u0441\u043e\u0432\u0435\u0442\u0443\u044e\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 HTTP \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438  <\/p>\n<pre><code class=\"php\">function getRequestHeaders() {     $headers = array();     foreach($_SERVER as $key =&gt; $value) {         if (substr($key, 0, 5) &lt;&gt; 'HTTP_') {             continue;         }         $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));         $headers[$header] = $value;     }     return $headers; } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 Content-Type\/Content-Length \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0432\u0435\u0440\u043d\u0435\u0442. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0442\u0432\u0435\u0442 \u0438\u043c\u0435\u0435\u0442 350+ \u043b\u0430\u0439\u043a\u043e\u0432.<br \/>  \u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0432 <a href=\"https:\/\/www.php.net\/manual\/en\/function.getallheaders.php#84262\" rel=\"nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> php  <\/p>\n<pre><code class=\"php\">&lt;?php if (!function_exists('getallheaders')) {     function getallheaders()     {            $headers = [];        foreach ($_SERVER as $name =&gt; $value)        {            if (substr($name, 0, 5) == 'HTTP_')            {                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;            }        }        return $headers;     } } <\/code><\/pre>\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\/524906\/\"> https:\/\/habr.com\/ru\/post\/524906\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">Rocket science \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 php-fpm, \u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 nginx. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0432 PHP \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f HTTP \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430?<\/p>\n<p>  1. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 <i>Accept<\/i>, <i>Host<\/i> \u0438\u043b\u0438 <i>Referer<\/i>?<br \/>  2. \u0417\u043d\u0430\u0435\u0442\u0435? \u0417\u0434\u043e\u0440\u043e\u0432\u043e! \u0410 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <i>Content-Type<\/i>, <i>Content-Length<\/i>?<br \/>  3. \u041d\u0438\u0447\u0435\u043c \u0432\u0430\u0441 \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0442\u044c, \u0430 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <i>X-Forwarded-For<\/i>?<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uw\/sm\/xj\/uwsmxji8b9ddwlydsmtmfo2bske.png\" alt=\"image\"><\/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-311985","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/311985","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=311985"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/311985\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}