一个域上的ProxyPass和DocumentRoot

时间:2013-04-25 20:28:10

标签: apache document-root proxypass

假设我有以下配置:

<VirtualHost domain.com>
    # Server names, admins, logs etc...

    ProxyVia On
    ProxyRequests Off
    <Location "/">
        ProxyPass http://localhost:8080/tomcat-webapp/
        ProxyPassReverse http://localhost:8080/tomcat-webapp/
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>

现在,我希望地址domain.com/forum显示我的MyBB论坛的内容,这些文件位于/var/www/forum目录中。如何做到这一点?

3 个答案:

答案 0 :(得分:32)

实际上,我使用以下代码解决了这个问题:

ProxyPass /forum !
ProxyPass / http://localhost:8080/tomcat-webapp/
ProxyPassReverse / http://localhost:8080/tomcat-webapp/
Alias /forum /var/www/forum

答案 1 :(得分:3)

建议使用mod_rewrite来执行ProxyPass而不是ProxyPass / ProxyPassReverse命令。

尝试类似:

RewriteRule  ^/forum   -  [L]
RewriteRule  ^/(.*)    http://localhost:8080/tomcat-webapp/$1  [P,L]
ProxyPassReverse /     http://localhost:8080/tomcat-webapp/

答案 2 :(得分:0)

我用:

<VirtualHost *:80>
#other irrelevant configs here
ProxyPass /forum http://localhost:8080/myBB
ProxyPassReverse /forum http://localhost:8080/myBB
ProxyPass / http://localhost:8081/tomcat-app
ProxyPassReverse / http://localhost:8081/tomcat-app
</VirtualHost>

你不必说&#34; tomcat-app&#34;如果您的tomcat应用程序是根应用程序。