【发布时间】:2020-08-21 18:25:09
【问题描述】:
有谁知道您是否可以在目录部分覆盖 ProxyFCGISetEnvIf 指令? apache 的 mod_proxy_fcgi 的文档说它在一个部分中有效,但我没有看到 ProxyFCGISetEnvIf 在目录中应用。
这是一个例子:
<VirtualHost *:443>
ServerName test7.com
ServerAlias
DocumentRoot /var/www/test
ProxyPassMatch ^(.*\.php)$ fcgi://127.0.0.1:9001/var/www/test/$1
ProxyFCGISetEnvIf "true" PHP_ADMIN_VALUE "open_basedir=/var/www/test:/usr/share/php:/usr/share/pear \n upload_tmp_dir=/tmp; \n session.save_path=/var/www/php_sessions;"
<Directory "/var/www/test/cooldir">
ProxyFCGISetEnvIf "true" PHP_ADMIN_VALUE "open_basedir=/var/www/test:/var/www:/usr/share/php:/usr/share/pear \n upload_tmp_dir=/tmp; \n session.save_path=/var/www/php_sessions;"
</Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/test7.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/test7.com/privkey.pem
</VirtualHost>
当我在“cooldir”目录中时,phpinfo() 显示 open_basedir 变量值没有改变。那么,mod_proxy_fcgi 中 ProxyFCGISetEnvIf 值的层次结构是什么?我想它应该像 nginx 一样工作,具有覆盖顶层的特定目录声明。例如,在 nginx 中,这是有效的:
location /cooldir {
root /var/www/test/;
index index.php index.html index.htm;
location ~ ^/cooldir/(.+\.php)$ {
try_files $uri =404;
root /var/www/test/;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param PHP_ADMIN_VALUE "open_basedir=/var/www:/tmp:/usr/share:/var/www/php_sessions \n upload_tmp_dir=/tmp \n session.save_path=/var/www/php_sessions";
include /etc/nginx/fastcgi_params;
limit_req zone=one burst=5;
}
}
感谢任何帮助。
【问题讨论】:
-
大家好。我注意到 ProxyFCGISetEnvIf 指令有些奇怪。值似乎在同一个 PHP-FPM 池中的 Apache 虚拟主机之间共享。如果一个 vhost 使用该指令定义了一个值(例如 open_basedir)而第二个 vhost 没有,则第二个 vhost 继承第一个 vhost 的 open_basedir 值。我必须在所有虚拟主机中明确定义 open_basedir。这不是问题,但是如果共享值,当同时处理不同 vhost 的两个或多个请求时,PHP-FPM 是否存在混合错误值的风险?
-
@David 我认为这是默认的工作方式。使用 php-fpm 代理时,nginx 配置做同样的事情。