如何将传入的请求重定向到特定的serverName到apache2中的不同服务器?

时间:2015-06-06 19:47:30

标签: apache redirect apache2 virtualhost virtual-hosts

我一直在玩apache2中的http-vhost.conf文件,以实现以下目标:

我有两个域名:

domain1.co.uk (app to be hosted by apache2 on port 80)

domain2.com   (app to be hosted by glassfish on port 8080)

我已在两个域上配置DNS以指向同一位置。

这是我的http-vhost.conf文件的内容:

NameVirtualHost *
<VirtualHost *>
    ServerName www.domain2.com
    ServerAlias domain2.com
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / http://domain2.com:8080/
    ProxyPassReverse / http://domain2.com:8080/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "/opt/lampp/htdocs/"
    ServerName www.domain1.co.uk
    ServerAlias domain1.co.uk
  # ErrorLog "logs/dummy-host2.example.com-error_log"
   # CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

问题在于,如果我将domain2.com放入浏览器,则会显示domain1.co.uk个应用。

请帮忙!

0 个答案:

没有答案