apache VirtualHost not functioning

Discussion in 'Server Operation' started by chipsafts, Nov 11, 2007.

  1. chipsafts

    chipsafts New Member

    running 2.0.54 on Fedora4

    httpd.conf has for the default hosting:
    Listen xxx.yyy.221.79:80

    for the virtual host:
    <VirtualHost 192.168.1.51:80>
    DocumentRoot /var/www/html
    ServerName forum.abcd.org
    </VirtualHost>

    tested with
    Code:
     /usr/sbin/httpd -S
    VirtualHost configuration:
    192.168.1.51:80        is a NameVirtualHost
             default server forum.abcd.org (/etc/httpd/conf/httpd.conf:973)
             port 80 namevhost forum.abcd.org (/etc/httpd/conf/httpd.conf:973)
    Syntax OK
    

    But from the server's command prompt,
    lynx http://xxx.yyy.221.79
    gives me a 403 error and then the 'Test Page for Apache'

    but
    lynx http://192.168.1.51 results in

    Looking up 192.168.1.51
    Making HTTP connection to 192.168.1.51
    Alert!: Unable to connect to remote host.

    lynx: Can't access startfile http://192.168.1.51/


    The firewall is setup to allow all port 80 requests and
    ping 192.168.1.51 works fine.

    what am I missing?
     
    Last edited: Nov 11, 2007
  2. archerjd

    archerjd New Member

    The directive 'Listen' sets the addresses and ports that the apache daemon listens to.
    The 'VirtualHost' directive sets the address and port that the virtual website will answer to.

    For example:
    Code:
    Listen 192.168.1.2:80
    Listen 192.168.1.2:443
    
    <VirtualHost 192.168.1.2:80>
    DocumentRoot /var/www/html
    ServerName forum.abcd.org
    </VirtualHost>
    
    <VirtualHost 192.168.1.2:443>
    DocumentRoot /var/www/html
    ServerName forum.abcd.org
    </VirtualHost>
    
    
    This tells apache to listen on IP 2 and ports 80 and 443 but it doesn't specify which site to deliver, VirtualHost does.

    from what I gather you have your server behind a firewall doing NAT to 192.168.1.51.
    If this is the case then you should have the directive 'Listen 192.168.1.51' so the apache server will listen on the right IP.:cool:
     
  3. chipsafts

    chipsafts New Member

    Thanks , that seems to have helped out quite a bit.
    Odd, RH9 did not require additional 'Listen' statements.

    Now to find out what the 403 error is about
    and then on to getting myBB to work :)
     
  4. archerjd

    archerjd New Member

    If you look at the config to RH9 it probably had an asteric (*) instead of the full IP address.
    This just tells apache to listen on all addresses.
     

Share This Page