How to redirect an incoming request to specific serverName to different server in apache2?

109 views Asked by At

I've been playing with the http-vhost.conf file in apache2 in order to achieve the following:

I got two domains:

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

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

I have configured the DNS on both domains to point to the same location.

This is the content of my http-vhost.conf file:

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>

The problem is that, if I put domain2.com in my browser, I reach domain1.co.uk app.

Please help!

0

There are 0 answers