How to tell what IP address Apache is receiving requests from??

Discussion in 'Apache' started by COAstroGeek, Nov 25, 2008.

  1. #1
    Hi all - I'm trying to set up IP based virtual hosts. This was working before as name based virtual hosts, but I need to turn on SSL for one of the sites, and doing that with name based virtual hosts was causing problems.

    So I've set up an IP alias - ifconfig now looks like this:

    eth0 Link encap:Ethernet HWaddr 00:18:8B:4A:8E:8A
    inet addr:192.168.0.175 Bcast:192.168.0.255 Mask:255.255.255.0
    inet6 addr: fe80::218:8bff:fe4a:8e8a/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:301644395 errors:0 dropped:0 overruns:0 frame:0
    TX packets:406606012 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:1510501581 (1.4 GiB) TX bytes:3723951858 (3.4 GiB)
    Interrupt:169 Memory:f8000000-f8011100

    eth0:0 Link encap:Ethernet HWaddr 00:18:8B:4A:8E:8A
    inet addr:192.168.0.177 Bcast:192.168.0.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    Interrupt:169 Memory:f8000000-f8011100

    And changed the VirtualHost statements in httpd.conf to

    <VirtualHost 192.168.0.175>
    #<VirtualHost *:80>
    DocumentRoot /var/www/domain1/html
    ServerName www.domain1.org:80

    ProxyRequests Off

    <Proxy http://www.space-track.org/SpaceTrackWS/*>
    Order deny,allow
    Deny from all
    Allow from all
    </Proxy>

    Alias /perl /var/www/domain1/cgi-perl
    ErrorLog logs/domain1_error_log
    CustomLog logs/domain1_access_log common
    </VirtualHost>

    <VirtualHost 192.168.0.177>
    DocumentRoot /var/www/domain2/html
    ServerName www.domain2.org
    Alias /perl /var/www/domain2/cgi-perl
    ErrorLog logs/domain2_error_log
    CustomLog logs/domain2_access_log common

    SSLEngine on
    SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt
    SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key

    Alias /icons/ "/var/www/domain2/html/icons/"

    <Directory "/var/www/domain2/html/icons">
    Options -Indexes
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>

    </VirtualHost>

    Domain1 works fine. But it I try to load a domain2 URL, I get the domain1 page (the sites are nearly identical) even though the url in the browser still says domain2.

    There is a firewall device in front of this server. They've given me a second external IP address which should be routed to the ip alias address on the server. I've confirmed that the DNS points to the correct external IP address with dig.

    What I think is happening is that the new IP address on the firewall is routing traffic to the domain1 IP address (192.168.0.175) on the server, rather then the ip-alias address for domain2 (192.168.0.177).

    How can I determine which address the requests are coming in from? Or is the behavior I'm seeing all the proof I need?
     
    COAstroGeek, Nov 25, 2008 IP
  2. sparek

    sparek Peon

    Messages:
    68
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need a NameVirtualHost for each IP address

    NameVirtualHost 192.168.0.175
    NameVirtualHost 192.168.0.177
    Code (markup):
    Also make sure that www.domain2.org is actually resolving to 192.168.0.177 and not 192.168.0.175
     
    sparek, Nov 25, 2008 IP