关于php:Vagrant box上的Apache反向代理-phpmyadmin错误重定向

关于php:Vagrant box上的Apache反向代理-phpmyadmin错误重定向

我正在运行一个带有端口转发 NAT 网络的 vagrant box(Debian Wheezy),通过 apache2 反向代理将浏览器重定向到它。

反向代理虚拟主机:

<VirtualHost *:80>
    ServerName vagrant-test.zk
    ServerAdmin webmaster@localhost

    ProxyPass / http://localhost:8080/

    ErrorLog ${APACHE_LOG_DIR}/vagrant-test.zk.error.log
    CustomLog ${APACHE_LOG_DIR}/vagrant-test.zk.access.log combined
</VirtualHost>

当浏览器指向时,一切正常http://vagrant-test.zk它显示了网站,而无需修改地址栏中的 URL。但是当我将浏览器指向http://vagrant-test.zk/phpmyadmin,它将 URL 更改为http://localhost:8080/phpmyadmin。PhpMyAdmin 工作正常,但我无法同时登录到 2 个 vagrant boxes phpmyadmin,因为似乎存在会话冲突,即使不同的 vagrant boxes 监听不同的 TCP 端口。

我认为问题出现在 /etc/phpmyadmin/apache.conf,但我不知道在哪里。

# phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_admin_flag allow_url_fopen Off
        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/
    </IfModule>

    <IfModule mod_fcgid.c>
        AddHandler fcgid-script .php
        FCGIWrapper /www/scripts/vagrant/php-fcgi .php
        Options +ExecCGI
    </IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authn_file.c>
    AuthType Basic
    AuthName "phpMyAdmin Setup"
    AuthUserFile /etc/phpmyadmin/htpasswd.setup
    </IfModule>
    Require valid-user
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
    Order Deny,Allow
    Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Order Deny,Allow
    Deny from All
</Directory>

有什么提示吗?

答案1

G4b0,

您需要在虚拟主机中添加反向代理指令:

<VirtualHost *:80>
    ServerName vagrant-test.zk
    ServerAdmin webmaster@localhost

    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080
    ErrorLog ${APACHE_LOG_DIR}/vagrant-test.zk.error.log
    CustomLog ${APACHE_LOG_DIR}/vagrant-test.zk.access.log combined
</VirtualHost>

相关内容