Forum Moderators: phranque

Message Too Old, No Replies

Ok, so I followed the instructions.

But the VHosts still wont work.

         

Stuperfied

1:30 pm on Apr 1, 2005 (gmt 0)

10+ Year Member



I went throught all the documentation on Listen, NameVirtualHost, VirtualHost, etc... I understood it and followed the directions. I setup my hosts file and double checked everything but no luck.

I can set the host file to whatever I want and the server works but as soon as I setup a virtualhost for one of the hosts, the whole thing comes crashing down.

I set the hosts to the following:

127.0.0.1 localhost
127.0.0.2 example.no-ip.com

I tried the virtualhosts as such:

NameVirtualHost localhost:80

<VirtualHost localhost:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web
ServerName localhost
</VirtualHost>

NameVirtualHost example.no-ip.com:80

<VirtualHost example.no-ip.com:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web/example
ServerName example.no-ip.com
</VirtualHost>

but that didnt work.
So I tried it like this:

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web
ServerName localhost
</VirtualHost>

NameVirtualHost 127.0.0.2:80

<VirtualHost 127.0.0.2:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web/example
ServerName example.no-ip.com
</VirtualHost>

But that didnt work either so I tried it with only one "NameVirtualHost localhost" for all virtualhosts, I tried a "*" for the NameVirtualHosts and VirtualHosts and I tried and tried and tried for 5 days now but still cant get the VirtualHosts working.

Someone Please Help Me, Im Going Nuts!

[edited by: jdMorgan at 4:08 pm (utc) on April 1, 2005]
[edit reason] Removed specifics per TOS. [/edit]

sitz

12:29 am on Apr 2, 2005 (gmt 0)

10+ Year Member



Well, for starters, I generally recommend that NameVirtualHost's argument be an IP address, not a hostname; saves Apache from having to look up the IP from the hostname at startup:

NameVirtualHost 127.0.0.1:80

Secondly, I generally recommend that all NameVirtualHost lines be next to one another, as it keeps the httpd.conf a bit more readable:


NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.2:80

<VirtualHost 127.0.0.1:80>
(config for this vhost)
</VirtualHost>

<VirtualHost 127.0.0.2:80>
(config for this vhost)
</VirtualHost>

Third, saying "it doesn't work" doesn't really help with troubleshooting. I'm assuming that when you access a particular virtualhost in a web browser, you don't see what you expect. So, what *do* you see? Are there any messages in the error log?

Stuperfied

1:16 am on Apr 3, 2005 (gmt 0)

10+ Year Member



Hosts file:

127.0.0.1 localhost
127.0.0.2 example.no-ip.com
127.0.0.3 stuper.no-ip.com
127.0.0.4 fortheorphs.tk
127.0.0.5 www.example.com.au
127.0.0.6 ISSSG.tk

Conf file:


NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.2:80
NameVirtualHost 127.0.0.3:80
NameVirtualHost 127.0.0.4:80
NameVirtualHost 127.0.0.5:80
NameVirtualHost 127.0.0.6:80

<VirtualHost 127.0.0.1:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web
ServerName localhost
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

<VirtualHost 127.0.0.2:80>
ServerAdmin sales@example.com.au
DocumentRoot C:/web/example
ServerName example.no-ip.com
</VirtualHost>

<VirtualHost 127.0.0.3:80>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web/stuperfied
ServerName stuper.no-ip.com
</VirtualHost>

<VirtualHost 127.0.0.4:80>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web
ServerName fortheorphs.tk
</VirtualHost>

<VirtualHost 127.0.0.5:80>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web/example
ServerName www.example.com.au
</VirtualHost>

<VirtualHost 127.0.0.6:80>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web
ServerName ISSSG.tk
</VirtualHost>

The access log reports an access, the error log reports no nothing.
Internet explorer reports:


The page cannot be displayed.
Jargon about please try the following.
Cannot find server or DNS error.

The standard Internet Explorer spoof page.
Any ideas?

[edited by: jdMorgan at 3:48 am (utc) on April 11, 2005]
[edit reason] Examplified [/edit]

sitz

4:07 am on Apr 3, 2005 (gmt 0)

10+ Year Member



The goal is is to determine which VirtualHost is serving the request. It should also be noted that Namebased virtualhosting means that all VirtualHosts *can* be bound to the same IP/port combination. With that in mind...

  • When you go to one of the IP addresses (127.0.0.2, for instance), do you get the site you expect?

  • If not, do you have Listen directives for those IP addresses?

  • Did you restart your browser after you modified the hosts file? IE doesn't recognize changes to the hosts file without an application restart.

  • If you set up CustomLog directives (each pointing to a unique logfile) for each of your VirtualHosts; does the request get logged in one of those logs, or in the main server log?
  • Stuperfied

    5:54 am on Apr 3, 2005 (gmt 0)

    10+ Year Member



    Thank you for your reply.
    Q. When I goto 127.0.0.2 do I get the page I expect.
    A. Unfortunately none of the pages will come up when using a name based url remotely. The only page that does work is the control panel when I type "http://220.***.21.36" which is the servers direct broadband internet connection IP. Every other page simply gives me the IE error page. However if I get on the server and access "http://fortheorphans.tk" localy, it works.

    Q. Do you have listen directives for those ip's.
    A. I have the listen directive set as "*:80".

    Q. Did I restart my browser after I modified the hosts file.
    A. I openned a new browser when I tried to access the server remotely from my computer and tried two of the name bassed url's mentioned but only got the IE error page. I also oppenned a new browser window when I tried to access the sites using the same 2 name bassed url's mentioned locally from the server however this time, the "http://fortheorphans.tk" name brought up the control panel page but the "http://example.no-ip.com" name failed and produced the IE error page.

    Q. If I setup custom logs do they get logged in the right place.
    A. Havent tried but will do so when I get back as im about to go out now.

    Thank you once again very much for helping me with this, I hope the information I have supplied is easily understood and helpfull.

    [edited by: jdMorgan at 3:49 am (utc) on April 11, 2005]
    [edit reason] Examplified. [/edit]

    sitz

    6:18 am on Apr 3, 2005 (gmt 0)

    10+ Year Member



    Unfortunately none of the pages will come up when using a name based url remotely.

    Define 'remotely'; you do know that any IP address that starts with "127." isn't going to be accessible from any host *except* the host itself, right? =)

    I openned a new browser when I tried to access the server remotely from my computer

    I don't think that's sufficient; you'll probably have to exit the browser completely and start it back up again. Or, to be safe, you could just reboot. =)

    Stuperfied

    10:41 am on Apr 3, 2005 (gmt 0)

    10+ Year Member




    Define 'remotely'; you do know that any IP address that starts with "127." isn't going to be accessible from any host *except* the host itself, right? =)

    Actually I dont know much about the accessability of different IP ranges at all. I know that different ranges require a different subnet mask but thats about it.

    This could be the problem. I want the websites to be able to be accessable over the internet like msn.com, nokia.com etc. If the IP range of "127" wont do that then which IP range should I use and should I still put it in the hosts file?

    sitz

    4:03 pm on Apr 3, 2005 (gmt 0)

    10+ Year Member



    I tell you three times and what I tell you three times is true; the hosts file is not critical (or even needed) for this to work. At all. Not even a little bit. Honest. =)

    All the hosts file does is provide IP->hostname mappings that can be used by the host the hosts file is on. If you want *other* hosts to to be able to look up the IP of your site, the domain needs to be registered with one of the domain registrars (dotster [dotster.com], domainmonger [domainmonger.com], etc) and the hostname placed in DNS. You can verify that a domain has been registered by using a 'whois' tool, such as GeekTools [geektools.com].

    Once this has been verified, the hostname needs to placed in DNS, mapped to the IP address of your server. You do NOT need a seperate IP address for each site *unless* you're going to be using SSL (HTTPS). Read [httpd.apache.org ] for more info on configuring name-based virtualhosts under Apache.

    Stuperfied

    12:23 am on Apr 4, 2005 (gmt 0)

    10+ Year Member



    Once this has been verified, the hostname needs to placed in DNS, mapped to the IP address of your server.

    Thankyou very much for your reply, I have a feeling we are getting close.
    Ok so I can put the hosts file back to standard and forget about it, thats good.

    Ok, "example.no-ip.com" and "stuperfied.no-ip.com" are registered with no-ip.com and are pointed at our servers Internet IP address. "fortheorphans.tk" and "ISSSG.tk" are registered with "http://www.dot.tk" which is another free domain name provider and also point at our servers Internet IP address. "example.com.au" however was registered by our host AVS Networks "http://www.avs.net.au" so I have no idea who its registered with but it currently points at their server and is a fully functional domain. When we get our server working properly we want to point "example.com.au" at our server.

    I should mention that all domain names do work but we have to map them directly to their directory on the server, however as soon as we setup a virtual hosts they stop working.

    So how do we place the host name in DNS and map it to the IP address of our server and what should the Virtual Hosts be set to?

    [edited by: jdMorgan at 3:50 am (utc) on April 11, 2005]
    [edit reason] Examplified. [/edit]

    sitz

    3:14 am on Apr 5, 2005 (gmt 0)

    10+ Year Member



    So how do we place the host name in DNS and map it to the IP address of our server and what should the Virtual Hosts be set to?

    In this case, registering them with no-ip.com has placed them in DNS; this can be verified by running 'host WHATEVER.no-ip.com' (had you registered your own domain, you'd then need to find DNS hosting for your domain and create the proper entries in your domain's zonefile).

    The only thing still required is NameVirtualHost entries for the IP you've registered with no-ip.com, and <VirtualHost> blocks for each site, configured with a ServerName foo.no-ip.com, or what have you. For instance:


    #
    # use your real IP here
    NameVirtualHost 192.168.1.100:80
    #
    # ...and here
    <VirtualHost 192.168.1.100:80>
    ServerName yourhostname.no-ip.com
    DocumentRoot /path/to/host/docroot
    (other directives here)
    </VirtualHost>

    ...and likewise for any other hosts. Multiple hostnames can be mapped to this IP address, provided that each has its own <VirtualHost block with the proper ServerName.

    Stuperfied

    7:52 am on Apr 5, 2005 (gmt 0)

    10+ Year Member




    NameVirtualHost *

    <VirtualHost *>
    ServerAdmin hurt_domain@hotmal.com
    DocumentRoot C:/web
    ServerName fortheorphs.tk
    ServerAlias fortheorphans.tk *.fortheorphs.tk
    </VirtualHost>

    <VirtualHost *>
    ServerAdmin hurt_domain@hotmal.com
    DocumentRoot C:/web/example
    ServerName www.example.com.au
    ServerAlias example.com.au *.example.com.au
    </VirtualHost>

    <VirtualHost *>
    ServerAdmin hurt_domain@hotmal.com
    DocumentRoot C:/web/ISSSG
    ServerName ISSSG.tk
    ServerAlias ISSSG.tk *.ISSSG.tk
    </VirtualHost>

    Now all my domain names are being refered to the first VirtualHost, they are all ignoring the rest of them. Whatever DocumentRoot I set the fortheorphans.tk VirtualHost to is the one that all sites are being sent to. Also if I try to set a virtual host for a no-ip.com domain, it all stops working again. The only thing I can think of is that maybe the .tk and no-ip.com servers dont send the host name in the header file. The www.example.com.au host is just for show, it really points at the AVS Networks server.

    Idea's?

    [edited by: jdMorgan at 3:52 am (utc) on April 11, 2005]
    [edit reason] Examplified. [/edit]