【问题标题】:Apache2 mod_proxy_fcgi ProxyFCGISetEnvIf Directory Specific OverrideApache2 mod_proxy_fcgi ProxyFCGISetEnvIf 目录特定覆盖
【发布时间】: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 配置做同样的事情。

标签: apache apache2 fastcgi


【解决方案1】:

根据我在 apache 用户邮件列表中收到的回复,您必须使用 &lt;Location&gt; 指令而不是 &lt;Directory&gt; 指令:

<Location "/webmail">
        ProxyFCGISetEnvIf "true" PHP_ADMIN_VALUE "open_basedir=/var/lib/roundcube:/etc/roundcube:/usr/share:/tmp:/var/www/php_sessions:/var/log/roundcube; \n upload_tmp_dir=/tmp; \n session.save_path=/var/www/php_sessions;"
</Location>

【讨论】:

    猜你喜欢
    • 2017-11-08
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    • 2015-08-22
    • 1970-01-01
    • 2021-01-04
    • 1970-01-01
    相关资源
    最近更新 更多