0

My server holds two IP 192.168.1.90 and 192.168.1.99 I want nginx to listen on 192.168.1.99 and Apache on 192.168.1.90 I also need to host multiple virtual hosts on apache.

tried modifying ports.conf of apache to

NameVirtualHost 192.168.1.90:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

And then I hosted a Virtual host in apache

<VirtualHost 192.168.1.90:80>
DocumentRoot /home/webmaster/www/thefactor/
ServerName www.XYZ.com
ServerAlias XYZ.cu.com

# Other directives here

</VirtualHost>

The problem is all the traffic, all request that comes to 192.168.1.90 irrespective of the domain name loads XYZ.com. ie: If i point ABC.com to 192.168.1.90 then when I browse to it, It loads XYZ.com page but the address in the address bar will remain ABC.com, so it is not a redirect.

Any Idea why this is happening

2 Answers 2

0

The first virtual host you define will be the "default" host. Thus all requests for domains not configured elsewhere will go to this first host.

If you want requests for domains not configured on a server, but directed to it anyway to be ignored you need to create a separate, "catch all" dummy virtualhost that does just refuses all requests, and that is listed before the othosts.

<VirtualHost 192.168.1.90:80>
    #Dummy Host denies all accesses.
    Order Allow, Deny
    Deny from all
</VirtualHost>

<VirtualHost 192.168.1.90:80>
    DocumentRoot /home/webmaster/www/thefactor/
    ServerName www.XYZ.com
    ServerAlias XYZ.cu.com

    # Other directives here
</VirtualHost>
1

You need to narrow the Listen directives to 192.168.1.90, like
Listen 192.168.1.90:80
Listen 192.168.1.90:443

otherwise Apache will listen on all IP's (and incoming requests hit the default virtualhost).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .