apache namevhosts problem


New to these forums, so i apologize if this is in the wrong place.

The problem:

I am trying to setup 2 virtual hosts on my apache webserver which is running opensuse 11.1

In the /etc/apache2/listen.conf file i have my:

NameVirtualHost *

in the /etc/apache2/vhosts.d/
I have 2 files, secure.conf and frontend.conf… both are copies of the template provided by apache.

When i restart apache, i get no errors at all. If i browse to the url that frontend.conf (domain.com) defines, it works, as expected… when i browse to the other one, secure.domain.com i get a page load error - address not found…

Im positive that both virtual host files are not the issue, but i can post them here if anyone would like to see them…

im out of ideas, any suggestions?

Sounds like secure.domain.com doesn’t resolve to your webserver’s IP address.

But to check that you have the namevhosts set up correctly, do:

/usr/sbin/httpd2 -S

and post the results.

This is what i get:

VirtualHost configuration:
wildcard NameVirtualHosts and default servers:
: is a NameVirtualHost
default server www.krm-tech.com (/etc/apache2/vhosts.d/front.conf:16)
port * namevhost www.krm-tech.com (/etc/apache2/vhosts.d/front.conf:16)
port * namevhost www.secure.krm-tech.com (/etc/apache2/vhosts.d/secure.conf:16)
Syntax OK

it almost looks like some default site is still there… i dont know

This make any sense?

Yes, it will work, provided www.secure.krm-tech.com resolves to your server’s IP address. From your browser’s error message, that doesn’t seem to be happening. You are aware that you have to point the vhost domain name to the IP address in DNS, right? You can’t just write a couple of conf files and have it work.

I added a line for it in /etc/hosts … is this not enough?

Do you mean registering sub.domain.com with a dns registry? Did not think you had to do that with namevhosts

It must resolve on all clients, not the server.

Here’s how namevhosts work:

  1. Web browser gets http://foo.example.com

  2. Resolves to IP address a.b.c.d

  3. Connects to a.b.c.d and sends the request including a line with Host: foo.example.com.

  4. Webserver sees that the request is intended for foo.example.com and uses the appropriate vhost. That Host: line makes all the difference.

If the client cannot resolve the vhost domain name, it doesn’t get past step 2.

If that is what you have to do with for all the clients you are interested in, yes, you have to do it.

If only a few internal clients use it and they are all Linux/Unix, and you can edit /etc/hosts on all of them, then that will work.

If all the clients are internal and use an internal DNS server to resolve requests and you can control that DNS server, then you can add it there.

but the domain is the same isnt it? krm-tech.com

I cant register a domain like secure.krm-tech.com

Sorry if im missing the point of your replies, trying to understand

secure.krm-tech.com is also a domain name. When Internet technical people say domain name, they don’t mean just the domain krm-tech.com. Every name which is registered is a domain name, e.g. secure.krm-tech.com, mail.krm-tech.com, www.krm-tech.com, and so forth.

The confusion of a domain name with a domain is understandable.

If you have a registrar for krm-tech.com, then it’s likely they give you the facility to add more domain names to the domain, like mail.krm-tech.com, www.krm-tech.com.

Thank you,

I added a new CNAME on the domain registrar im using, things are working as i expected.

Thanks for clarifying for me.