首页 > 解决方案 > Apache2 mod_proxy_fcgi ProxyFCGISetEnvIf 目录特定覆盖

问题描述

有谁知道您是否可以在目录部分覆盖 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;
    }
}

任何帮助表示赞赏。

标签: apacheapache2fastcgi

解决方案


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

<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>

推荐阅读