LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-30-2002, 10:29 AM   #1
nickblue
LQ Newbie
 
Registered: Nov 2002
Posts: 3

Rep: Reputation: 0
Unhappy named based virtual hosting newbie


I am a newbie on redhat and 8.0 and I am trying make name based virtual hosting work.

Right now, any virtual host resolves to the default server and apparently and ignores the virtual host directives. My httpd.conf files contains the below although I've tried the NameVirtualHost different ways without result. It seems like no matter what I do any virtual host resolves to the default server:

NameVirtualHost *:80

<VirtualHost *>
ServerName nbsweb.net:80
ServerAlias www.nbsweb.net
DocumentRoot /var/www/html/
</VirtualHost>

<VirtualHost *>
ServerName delsound.com:80
ServerAlias www.delsound.com
DocumentRoot /var/www/html/delsound/
</VirtualHost>

I have tried a private IP, WAN IP listed in the dns entry, with and without port# in the VirtualHost line without success. I am running one static IP and trying to do virtual hosting for more than one domain.

any insight would be greatly appreciated!
 
Old 12-01-2002, 10:55 AM   #2
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Any Virtual names must be specified in <VirtualHost www.xxx.com > </VirtualHost> tags,
eg
<VirtualHost www.xxxx.com>
DocumentRoot /var/www/xxxx.com
ServerName www.xxxx.com
</VirtualHost>

I add "NameVirtualServer xx.xx.xx.xx" with my ip address to the httpd.conf to catch any direct ip requests.
The first <VirtualHost > specified will become the default this way.
The default pages are served when apache cannot find a matching name for the incoming request.
You must have a dns server with an exact matching name pointing to this ip address, so do
dig www.xxxx.com
and make sure you can resolve the exact VirtualHost names.

From a command line type "httpd -S" to check the VirtualHost configurations.

Last edited by peter_robb; 12-01-2002 at 10:59 AM.
 
Old 12-01-2002, 11:13 AM   #3
clavius
Member
 
Registered: Dec 2002
Location: Romania, Tg-Jiu City
Distribution: Slackware
Posts: 35

Rep: Reputation: 15
Quote:
Originally posted by peter_robb
Any Virtual names must be specified in <VirtualHost www.xxx.com > </VirtualHost> tags,
eg
<VirtualHost www.xxxx.com>
DocumentRoot /var/www/xxxx.com
ServerName www.xxxx.com
</VirtualHost>

Not necessary. You can leave *
Quote:
I add "NameVirtualServer xx.xx.xx.xx" with my ip address to the httpd.conf to catch any direct ip requests.
I think this is his problem.
So, just uncomment the line with NameVirtualSever and restart apache.
Also, in new versions of Apache, you can put * after NameVirtualServer
Quote:
From a command line type "httpd -S" to check the VirtualHost configurations.
 
Old 12-01-2002, 12:29 PM   #4
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
The NameVirtualServer must be there or httpd will try to make all the specified VirtualHosts the default one.

I tried (to be sure) and the error messages are quite explicit.
 
Old 12-02-2002, 05:45 PM   #5
nickblue
LQ Newbie
 
Registered: Nov 2002
Posts: 3

Original Poster
Rep: Reputation: 0
Peter,

Thank you so much for replying.

1. I was unable to use the NameVirtualServer directive as I got an error - evidently it's not configured for the version of apache that comes with redhat 8.0.

2. I tested as per your instructions but to no avail.

3. I wiped the box and completely reinstalled, using the gnome gui and the httpd tool provided and got the following results:

The default virtual server appears to work as name-based; however when I add a second virtual host, both the default virtual host as well as the newly created virtual host now reolve to the default server /var/www/html rather than the respective document root such as /var/www/xxxx.com directory...argghh.

Again any suggestions are very much appreciated.

Nick
 
Old 12-02-2002, 08:47 PM   #6
fragglehorn
Member
 
Registered: Oct 2002
Location: I-Town, NY
Distribution: Debian, Slackware
Posts: 130

Rep: Reputation: 15
Nick,

Do you have a DNS record set up anywhere for this domain name? It doesn't have to be registered, but you do need someone's DNS pointed at your IP address.
 
Old 12-02-2002, 08:55 PM   #7
nickblue
LQ Newbie
 
Registered: Nov 2002
Posts: 3

Original Poster
Rep: Reputation: 0
fragglehorn,

Yes. thanks - it's on ns1.nbsweb.net; It's wierd but when I did not use the gnome gui tool and just edited httpd.conf based on the default virtual host created by the gnome gui tool...it works...

It's as if the gnome gui tool just did not work. It could create the default virtual host but not other virtual host. Only by imitating the syntax of the default virtual host entry, then editing it for the respective virtual host, it worked.

I'm disappointed in the httpd gnome gui - it didn't help me; it just got in the way. I might go ahead and just uninstall the gnome desktop even though I really like it.

Thanks.

Best,
Nick
 
Old 06-10-2003, 10:48 PM   #8
robbfen
LQ Newbie
 
Registered: Jun 2003
Posts: 16

Rep: Reputation: 0
Hi Everyone,

Well thanks for the help from this Q & A session because I was able to piece things together and got my Virtual Hosting to work. Man I will never use the HTTPD server config tool again. Had to do it by hand. Anyway if you go to www.designtime.ca you will just see a logo and if you go to www.sablestrokes.ca you will see the logo as well as the page I am working on for someone. The exact code I used with Redhat 8 was:

<VirtualHost *:80>
Servername designtime.ca
ServerAlias www.designtime.ca
DocumentRoot /var/www/html/www.designtime.ca
</VirtualHost>

then the same for www.sablestrokes.ca

Also I used NameVirtualHost *:80 to match this with each VirtualHost and voila! It works great.

Thanks for the help everyone.
 
Old 06-10-2003, 10:54 PM   #9
fragglehorn
Member
 
Registered: Oct 2002
Location: I-Town, NY
Distribution: Debian, Slackware
Posts: 130

Rep: Reputation: 15
Cool, glad we could all help.

Yet another example of why you should ALWAYS use the command line to edit config files.

Welcome to LQ!
 
Old 08-04-2003, 11:39 PM   #10
Impala
LQ Newbie
 
Registered: Aug 2003
Location: Boston
Posts: 2

Rep: Reputation: 0
robbfen- adding :80 inside the <VirtualHost *> did the trick! I never would have thought it! thx!

All together what i came up with was:


NameVirtualHost *:80

<VirtualHost *:80>
...directives
</VirtualHost>

<VirtualHost *:80>
...directives
</VirtualHost>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
name based virtual hosting jkmartha Linux - Software 4 08-04-2005 09:21 AM
name based virtual hosting adm1329 Linux - Networking 5 05-05-2004 11:30 AM
Trouble with Named based Virtual hosting in Apache 2 IanChristie Linux - Networking 16 11-07-2003 02:04 PM
reverse dns for named based hosting naughtymutt Linux - Networking 1 10-31-2002 05:56 AM
name-based virtual hosting and corresponding DNS entries roba Linux - General 0 08-14-2002 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration