﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
1312	In fastcgi_pass does not correctly handle variables	sleuthhound@…		"I use Debian 8.8 (jessie) php5-fpm 5.6.30 and nginx/1.13.2

My typical config:

server {
        listen XX.XX.XX.XX:80;
        server_name DOMAIN.ru;

        root /var/www/DOMAIN.ru/web;
        index index.php index.html index.htm;

        set $fastcgipass unix:/var/lib/php5-fpm/webXX.sock;
        #set $fastcgipass 127.0.0.1:9031;

        #rewrite ^/phpinfo/(.*)$ /i.php last;

        location / {
                try_files $uri $uri/ /index.php;
        }

        location ~ \.php$ {
                try_files       $uri = 404;
                include         /etc/nginx/fastcgi_params;
                fastcgi_pass    $fastcgipass; # <---- Problem in use rewrite last
                #fastcgi_pass   unix:/var/lib/php5-fpm/webXX.sock; # <----- No problem in using rewrite last
                fastcgi_param   HTTPS $fastcgi_https;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}

Today i decided to write a rewrite rule using last and came across an error of the form:
2017/07/07 11:09:19 [error] 15511#15511: *183067 no host in upstream """", client: XX.XX.XX.XX, server: DOMAIN.ru, request: ""GET /phpinfo/ HTTP/1.1"", host: ""DOMAIN.ru""

My simple rewrite:
rewrite ^/phpinfo/(.*)$ /i.php last;

# cat /var/www/DOMAIN.ru/web/i.php
<?php
echo ""OK"";
?>

# curl -D - -o /dev/null -s http://DOMAIN.ru/phpinfo/
HTTP/1.1 500 Internal Server Error
Server: nginx
Date: Fri, 07 Jul 2017 06:09:19 GMT
Content-Type: text/html
Content-Length: 186
Connection: close

A detailed study of the problem showed that the whole thing is in the line
fastcgi_pass    $fastcgipass;

i will write
fastcgi_pass   unix:/var/lib/php5-fpm/webXX.sock;

then is no problem with rewrite

# curl -D - -s http://DOMAIN.ru/phpinfo/
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 07 Jul 2017 06:34:13 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive

OK


Using tcp with php5-fpm does not solve the problem.
set $fastcgipass 127.0.0.1:9031;
"	defect	closed	critical		nginx-module	1.13.x	invalid			Linux XXXXX 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u1 (2017-02-22) x86_64 GNU/Linux	nginx version: nginx/1.13.2
