Virtual Hosts not working properly

Discussion in 'Installation/Configuration' started by Ashaman074, May 11, 2007.

  1. Ashaman074

    Ashaman074 New Member

    I am having some problems and hopefully someone here can help shed some light on them.

    This is the second linux/apache server I have set up. The first one was several years ago; but at the time I hosted a website and virtual sites using the process outlined here:http://www.onlamp.com/pub/a/apache/2003/07/24/vhosts.html which worked fine.

    I now have a new server running Ubuntu (Edgy) & Apache. When I read about ISPconfig, I thought it would provide a simple and easy method of managing our website as well as adding or removing additional virtual sites I might want to add. The thought was that by using this, I would avoid manual editing configuration files.

    I went ahead with the installation which seemed to go as planned. However, after creating the websites, trying to access them from a browser they all of them arrived at the same/common destination of /var/www and would list the contents. This folder contains folders named "web1, web2, etc. as well as links such as www.site1.com (linking to web1), www.site2.com (linking to web2), etc.) so it looks like ISPConfig created them, but for some reason they aren't accessed when the address is put into the Browser. I do not know why this is happening, shouldn't ISPConfig have configured them for me?

    Thinking maybe not, I remembered the first link I used at onlamp and tried that. It seemed to work, though I think that maybe that method is now outdated...as I found a newer guide at http://www.debuntu.org/2006/02/22/7-virtual-hosting-using-apache-2.

    I then tried this method. However, after doing that, I am now getting the message "[warn] VirtualHost site2.com:0 overlaps with VirtualHost site1.com:0, the first has precedence, perhaps you need a NameVirtualHost directive.

    Can anyone tell me if I am even on the right path here? The first link I sent seems to be older, so I abandoned it, the second seemed better suited to what I was trying to do, but it doesn't seem to be working, and I still am wondering if I should have had to try either or if ISPConfig should have done it for me but didn't because there is another issue!

    I have been searching like crazy the last couple days, but it is difficult when I am not sure which direction I should even be following...

    Any pointers/help would be appreciated!
     
  2. Ashaman074

    Ashaman074 New Member

    OK, a little more beating my head against the wall and I think I realized what the last error was saying.

    I think that basically I had two different methods of doing the same thing...ISPConfig creates the virtual hosts in the /etc/apache2/vhosts/vhosts_ispconfig.conf file. I then used the method in the second web link (the debuntu.org one) to create virtual host conf files in the /etc/apache2/sites-available.

    As a result, it was two methods of doing the same thing, sound reasonable?

    I noticed that in the Apache section of webmin (which is also installed) the virtual hosts I had created were listed twice, removing my entries seems to have resulted in them only being listed once, and the error I listed in the last post being eliminated.

    Unfortunately, I am also right back where I started, with the virtual hosts not working again. Entering the IP directly or typing any of the domains just lists the contents of /var/www.

    There must be something is ISPConfig I am missing?

    TIA!!
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Please create the websites in ISPConfig. Ddo not use webmin together with ISPConfig and do not create any sites manually in /etc/apache2/sites-available!

    You do not need to configure anything manually, the complete vhost configuration is done by ISPConfig. To preare your server for ISPConfig, please use one of the guides listed on the ISPconfig documentation page.

    Is your server behind a roter? Then you must use your interna (privete) IP address for the websites and not your external IP.
     
  4. Ashaman074

    Ashaman074 New Member

    Thanks for the post - I actually did use a guide, "The Perfect Setup - Ubuntu 6.10 Server (Edgy Eft)
    ", and it all went smoothly. Thanks for the information regarding configuration.

    I now have the Virtual hosts working (for web access anyway). This server is also the firewall; and it is performing PAT. Webmin actually helped point me in the right direction; if not configure anything.

    It seems that my Vhosts_ispconfig.conf file listed sites like this "ServerName www.server1.com:80" I removed the "80" from the end, and they seem to be working fine! Does that tell us anything useful? I don't know why it happened or was a problem...

    The one problem I do still see right off is that entering the external IP directly does not bring up the "shared IP" website, but instead lists the contenet of /var/www. I will continue checking this out, but again any suggestions are appreciated.

    It seems the problem is related to using *, the internal IP, or the internal IP:80 ....?

    Here is a section of my .conf file:

    ###################################
    #
    # ISPConfig vHost Configuration File
    # Version 1.0
    #
    ###################################
    #
    NameVirtualHost 10.0.0.1:80
    <VirtualHost 10.0.0.1:80>
    ServerName localhost
    ServerAdmin root@localhost
    DocumentRoot /var/www/sharedip
    </VirtualHost>
    #
    #
    ######################################
    # Vhost: www.thelawrencebarn.com:80
    ######################################
    #
    #
    <VirtualHost *>
    ServerName www.thelawrencebarn.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/web2/web
    ServerAlias thelawrencebarn.com
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    ScriptAlias /cgi-bin/ /var/www/web2/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
    ErrorLog /var/www/web2/log/error.log
    AddType application/x-httpd-php .php .php3 .php4 .php5
    <Files *.php>
    SetOutputFilter PHP
    SetInputFilter PHP
    </Files>
    <Files *.php3>
    SetOutputFilter PHP
    SetInputFilter PHP
    </Files>
    <Files *.php4>
    SetOutputFilter PHP
    SetInputFilter PHP
    </Files>
    <Files *.php5>
    SetOutputFilter PHP
    SetInputFilter PHP
    </Files>
    php_admin_flag safe_mode On
    php_admin_value open_basedir /var/www/web2/
    php_admin_value file_uploads 1
    php_admin_value upload_tmp_dir /var/www/web2/phptmp/
    php_admin_value session.save_path /var/www/web2/phptmp/
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Alias /error/ "/var/www/web2/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web2/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web2/user/$1/web/$3
    </VirtualHost>
    #
     
    Last edited: May 11, 2007
  5. falko

    falko Super Moderator Howtoforge Staff

    It must be internal IP:80.

    and please make sure that the IP address you use is listed in the output of
    Code:
    ifconfig
     
  6. Ashaman074

    Ashaman074 New Member

    Thanks for the reply and confirming that

    As you can see in my file, the first section is:

    NameVirtualHost 10.0.0.1:80
    <VirtualHost 10.0.0.1:80>
    ServerName localhost
    ServerAdmin root@localhost
    DocumentRoot /var/www/sharedip
    </VirtualHost>

    So that is correct, right?

    But then, later it had the lines:

    <VirtualHost 10.0.0.1:80>
    ServerName www.thelawrencebarn.com:80

    This is where things broke down and didn't work properly until I changed it to:

    <VirtualHost *>
    ServerName www.thelawrencebarn.com

    Then it seemed to work properly. I do not know why this is. Unfortunately, the first section still does not seem to work properly, as typing the server's IP into a web browser does not bring up the "sharedip" page. It lists the directory contents instead. Any other ideas?

    I am wondering if I should just abandon this whole path, as the idea was to simplify things; but it is turning into a diversion from the project at this point, and I don't know what else to try.

    Also - IFConfig does list 10.0.0.1.

    Thanks!
     
  7. falko

    falko Super Moderator Howtoforge Staff

    What's the output of
    Code:
    netstat -tap
    ? Your Apache does listen on port 80, doesn't it?
     
  8. Ashaman074

    Ashaman074 New Member

    Yes, I believe it did. I really WANT to understand, so today I started again. I followed the pefect setup guide ONLY, and now it seems that websites function properly.

    I am now thinking that my configuration had to somehow be the cause. I wanted this server to function as a DHCP/firewall server for an internal network as well (and had configured it as such - hence the 10.0.0.1 address).

    Should ISPConfig's web interface be accessed from an external IP address? The Perfect Setup guide uses internal addresses (192.x.x.x), but the Godaddy DNS guide uses external IPs (64.x.x.x) so I am not sure what is supposed to happen in between.

    The perfect setup guide didn't talk about setting up a second network interface - was it written with an internal IP address in mind, or an external address in mind? I would think external since it needs to be accessible for web traffic, but it used an address that isn't accessible to the web (192.x.x.x).

    I have two network interfaces on my machine, and am wondering if that was where I went wrong? Or maybe all these questions are really dumb sounding and I am not making any sense? :)

    I have to be getting close....right?

    Am I making any sense?
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig is not build to run it on a router with two network interfaces. If you are in a a private network, you use internal IP addresses for the websitesa nd external IP addresses for the DNS records. generally you should use a external router and do not run it on the ISPConfig server for security reasons.
     
  10. Ashaman074

    Ashaman074 New Member

    Oh, I see. I used ClarkConnect prior to this; that is what got me used to the Firewall/web/Email all-in-one approach I guess. After re-reading the ISPConfig documentation and installing a second time, I began to wonder.

    Sounds like I need to re-think the network roles and layout and start again :)

    So is it correct to say that normally you would set ISPConfig behind a firewall and use port forwarding/IP mapping with an internal IP address?

    It is a security risk to have it set up with an external IP address (and presumably the web admin page accessed via an external address)?

    I am having difficulty now seeing where it would reside on the network.
     
    Last edited: May 15, 2007
  11. falko

    falko Super Moderator Howtoforge Staff

    You can do it that way, or you can install ISPConfig on a server with a public IP address (in a data center, for example).

    No.
     
  12. Ashaman074

    Ashaman074 New Member

    Great, think I have a better understanding now. Thanks for your help guys!
     

Share This Page