PDA

View Full Version : Virtual Hosts


myriad360
09-05-2006, 10:22 PM
Hey there, I am sure this has been discussed before, but I had no luck searching for it. Basically I am trying to get multiple site to run of my server here at home. I think I understand the Server Alias part in the Apache httpd.conf; but maybe I am incorrect. I have 2 virtual hosts, we will call them site1 and site2. Now, I have a DNS at www.no-ip.com that says www.site1.no-ip.info and www.site2.no-ip.info belong to 11.22.33.444:90 (I have to use the 90 port).

To my understanding, if each Virtual Host has its repective Server Alias's correct, then the Virtual Host for site1 should pick up a request for www.site1.no-ip.com, etc. Correct? Is this my fault it doesn't?

Something I should mention is that No-IP.com is free, and so I suspect their may be something their service is messing up on. One thing that I suspect is that when you ask for www.site1.no-ip.com (as if the Apache server was setup without Virtual Hosts or anything), instead of displaying www.site1.no-ip.com in the address bar, it actually displays the IP address. Maybe this is no a DNS service after all, yes?

I appreciate any help anyone has to offer.

Beagle
09-06-2006, 07:07 PM
yeah, that's not a DNS at all if it just redirects to the IP.

I would recommend afraig.org, see if they're up and running (they recently were attacked). There's another free dns out there, but I'm not sure.

That could most definitely be the issue.

schleppel
09-06-2006, 11:00 PM
You can get proper DNS from NoIP.com, but if it's set up properly, you need the port in the URL after the domain, eg. www.site2.no-ip.info:90. But afraid.org is better.

What <VirtualHost> code are you using? You need to set a ServerName aswell as/instead of a SeverAlias.

http://httpd.apache.org/docs/2.0/vhosts/name-based.html#using

myriad360
09-08-2006, 06:24 PM
Thanks for the reply, I forgot, I need to know how to use the coding text box for the forum to display the code. Basically, I think I am trying another route than the DNS; I am using a different port for every virtual host. But I am still having problems, it is only displaying the default virtual host, even when I ask for my IP address externally and as for port 91, for instance. I will like to display the code just as soon as I can figure out the code text box.

Thanks much!

myriad360
09-08-2006, 06:25 PM
Listen 90
Listen 91

<VirtualHost 127.0.0.1:90>
ServerAdmin admin@localhost
DocumentRoot "X:/"
ServerName localhost
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log common
</VirtualHost>

<VirtualHost 127.0.0.1:91>
DocumentRoot "X:/web/wintegra/6th version"
ServerName wintegraproto
</VirtualHost>

myriad360
09-08-2006, 06:46 PM
Sorry, I left out the #NameVirtualHost *
Here is the full code:

Listen 90
Listen 91

NameVirtualHost 127.0.0.1:90
NameVirtualHost 127.0.0.1:91

<VirtualHost 127.0.0.1:90>
ServerAdmin admin@localhost
DocumentRoot "X:/"
ServerName localhost
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log common
</VirtualHost>

<VirtualHost 127.0.0.1:91>
DocumentRoot "X:/web/wintegra/6th version"
ServerName wintegraproto
</VirtualHost>

schleppel
09-08-2006, 06:52 PM
You don't need multiple ports, this should work fine:
Listen 90

NameVirtualHost 127.0.0.1:90

<VirtualHost *:90>
ServerAdmin admin@localhost
DocumentRoot "X:/"
ServerName localhost
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log common
</VirtualHost>

<VirtualHost *:90>
DocumentRoot "X:/web/wintegra/6th version"
ServerName wintegraproto
</VirtualHost>

If you really want to use a different port for each the ServerName shouldn't matter:
Listen 90
Listen 91

NameVirtualHost *:90
<VirtualHost *:90>
ServerAdmin admin@localhost
DocumentRoot "X:/"
ServerName 127.0.0.1
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log common
</VirtualHost>

NameVirtualHost *:91
<VirtualHost *:91>
DocumentRoot "X:/web/wintegra/6th version"
ServerName 127.0.0.1
</VirtualHost>

myriad360
09-08-2006, 08:08 PM
If I enter in http://localhost:90 in my browser, I get the correct site per the script, same when I enter in http://localhost:91 . But when I access the server externally (via laptop off the coffee shop wi-fi, etc), it only gives me the first one, and not the one it should when I ask it http://71.36.29.148:91 .

You can see for your self, http://71.36.29.148:90 and http://71.36.29.148:91 . Same site! Weird. I have made sure all of my port forwarding was correct as well. And this can't be a DNS problem right now if we are only using IP addresses, right? I am sure I am missing some step to the process, but I am not having luck finding much doc on this matter of more external requests.

schleppel
09-08-2006, 08:40 PM
Worked fine for me in Apache 1.3 and 2.0 (haven't tried 2.2). What version of apache are you using? What happens if you put the port 91 lines before the port 90 lines?

myriad360
09-08-2006, 10:14 PM
I am using Apache 1.3 right now, just the typical 1.3 install. I switched the script so that the Virtual Host for 91 port it first, but it may be a little while today before I can test it externally. Works the same internally, if that means anything.

Thanks for the idea, I wonder if it is defaulting to the first Virtual Host or the stand alone config for the server? Since they are the same... we will see with this switch you mentioned.

myriad360
09-09-2006, 07:57 AM
And there is no difference, I can do whatever I want to the virtual hosts and it only makes a difference internally, not externally. Which means that it is just using the standalone config, which is weird because I do not have 'Port' enabled in the whole script, just 'Listen'.

Could this be a 'host' file problem?

myriad360
09-09-2006, 08:08 AM
This is the link that I am trying to follow...
http://httpd.apache.org/docs/1.3/vhosts/examples.html#port

Somewhere though I am still messed up.

schleppel
09-09-2006, 08:34 PM
Have you tried this?
Listen 90
Listen 91

<VirtualHost _default_:90>
ServerAdmin admin@localhost
DocumentRoot "X:/"
ServerName 127.0.0.1
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log common
</VirtualHost>

<VirtualHost _default_:91>
DocumentRoot "X:/web/wintegra/6th version"
ServerName 127.0.0.1
</VirtualHost>

Edit2: If that doesn't work could you attatch your configuration files?

myriad360
09-11-2006, 02:16 AM
That worked! Beautiful! I am going to continue testing with this; the Apache config file is still a mystery to me in ways, but I appreciate extremely your help with this. You can try the links if you like;
http://71.36.29.148:90
http://71.36.29.148:91

How did you find this solution, by the way?

schleppel
09-11-2006, 08:35 PM
Good.

I was looking at the page you linked to. I think it was a problem with the NameVirtualHost lines. It also uses _default_.