大网数据广告活动
服务器运维问答

Missing PATH_INFO on Apache 2.4 / php5.6-fpm / proxy_fcgi

· 52CE 我爱测

I'm using Debian 9 with PHP-FPM 7.0.26-2 & 5.6.32-1 from repository deb.sury.org. The same configuration is working fine on a Debian 8 server with PHP-FPM 5.6.30 I've copied the pool.d/user.conf from that server. Both php.ini fil…

问题原文

原帖链接 · Esa Jokinen · CC BY-SA 3.0

I'm using Debian 9 with PHP-FPM 7.0.26-2 & 5.6.32-1 from repository deb.sury.org. The same configuration is working fine on a Debian 8 server with PHP-FPM 5.6.30

  • I've copied the pool.d/user.conf from that server.
  • Both php.ini files are having cgi.fix_pathinfo=1.
  • The parameter is also forced using php_admin_value[cgi.fix_pathinfo] = 1.
  • Both servers uses this pool similarly from <VirtualHost> context with:

    ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/user.sock|fcgi://localhost/home/user/public_html
    

Now, there's an AJAX page that needs to read path from PATH_INFO (possibly PATH_TRANSLATED). However, while these variables have correct content on the Debian 8 server:

["SCRIPT_NAME"]=>
string(14) "/path/ajax.php"
["ORIG_SCRIPT_NAME"]=>
string(25) "/path/ajax.php/para/meters"
["PATH_INFO"]=>
string(12) "/para/meters"
["PATH_TRANSLATED"]=>
string(34) "/home/user/public_html/para/meters"

They seem to work differently on the fresh Debian 9 + dub.sury.org:

["SCRIPT_NAME"]=>
string(25) "/path/ajax.php/para/meters"
["PATH_TRANSLATED"]=>
string(22) "/home/user/public_html"

And the prameters ORIG_SCRIPT_NAME and PATH_INFO are completely missing.

已采纳解答

原帖链接 · Esa Jokinen · CC BY-SA 3.0

It was the way I used the proxy_fcgi. As explained in the examples for mod_proxy_fcgi:

You can also force a request to be handled as a reverse-proxy request, by creating a suitable Handler pass-through. - - The benefit of this form is that it allows the normal mapping of URI to filename to occur in the server, and the local filesystem result is passed to the backend. When FastCGI is configured this way, the server can calculate the most accurate PATH_INFO.

So I replaced my

ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/user.sock|fcgi://localhost/home/user/...

with a Handler & Worker:

    <FilesMatch "\.php$">
            SetHandler  "proxy:unix:/run/php/user.sock|fcgi://localhost"
    </FilesMatch>
    <Proxy "fcgi://localhost/" enablereuse=on max=10>
    </Proxy>

Now all the AJAX request are working fine.

BONUS: If some knows why the ProxyPassMatch was able to calculate the the PATH_INFO before on my Debian 8 / Apache 2.4.10 / PHP-FPM 5.6.30 but not with Debian 9, that would be awesome.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-12-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。