Problem getting from localhost on virtual host

Discussion in 'Installation/Configuration' started by OnTheRun, Jan 5, 2006.

  1. OnTheRun

    OnTheRun New Member

    Hello all,
    I have the following problem:

    I'm using a php-script, which uses the fsockopen-function. The scrip gets executed from the server (i.e. domain.ch) itself on itself:

    PHP:
    fsockopen ("www.domain.ch"80$errno$errstr30);
    First he didn't knew his own domains, so I had the idea, that it sure wouldn't be bad to add the domainnames to /etc/hosts.
    The server now knows the domains, but doesn't forward them correctly to the
    corresponding vhost.

    The vhost is i.e.:

    Code:
    <VirtualHost 10.0.0.17:80>
    ServerName www.domain.ch:80
    ServerAdmin webmaster@domain.ch
    DocumentRoot /var/www/webX/web
    ServerAlias www.domain.ch domain.ch ftp.domain.ch subdomain.domain.ch subdomain2.domain.ch subdomain3.domain.ch
    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/webX/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
    ErrorLog /var/www/webX/log/error.log
    
    He forwards not to /var/www/webX/web as it's defined in the vhosts-file, but he forwards to /var/www/apache2-default (I tried this by using links2 www.domain.ch on the server itself).

    The system is Debian 3.1 with apache 2 and ISPConfig.

    I checked the logs. In error.log is nothing, in access.log the following:

    Code:
    127.0.0.1 - - [05/Jan/2006:09:06:52 +0100] "GET / HTTP/1.1" 302 390 "-" "Links (2.1pre16; Linux 2.4.32 i686; 80x24)"
    127.0.0.1 - - [05/Jan/2006:09:06:52 +0100] "GET /apache2-default/ HTTP/1.1" 200 1457 "-" "Links (2.1pre16; Linux 2.4.32 i686; 80x24)"
    Has anybody a clue how I can tell the server to use the vhosts-file when a request comes from 127.0.0.1/localhost?

    Thanks and with kind regards
     
  2. falko

    falko Super Moderator

    Please check if www.domain.ch is used somewhere else in your main Apache configuration file. Also make sure the Vhosts_ispconfig.conf is included in your main Apache configuration.
     
  3. OnTheRun

    OnTheRun New Member

    Hello,
    thank you for your answer.
    The domain.ch isn't anywhere in /etc/apache2/apache2.conf. Vhots_ispconfig.conf gets included in the last line of apache2.conf:

    Code:
    Include /etc/apache2/vhosts/Vhosts_ispconfig.conf
    Could it be, that the function fsockopen doesn't send any headers? And links2 from console neither? Because from outside it works like a charm to reach the domain domain.ch. Just from the server itself I get forwarded to apache2-default. But exactly that's the problem, because I need to call the function fsockopen from the server itself.

    Thanks and with kind regards.
     
    Last edited: Jan 5, 2006

Share This Page