Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ISP Help....Virtual Hosting/DNS entries 1

Status
Not open for further replies.

force5

ISP
Nov 4, 2004
118
US
A little background of my situation:
I work for a local ISP and we are adding a new webserver to run Apache 2.0. We are going to leave our currently hosted websites(about 100) on our ISS box, and all new sites will get set up on Apache. I have RedHat 9.0 and am using the Apache that is bundled with it. I have been "Thrown to the Wolves" and expected to get this up and running. I have read "Teach Youself Apache in 24 hours" and also 1/2 of the Apache Administrators Handbook and not to mention about 3 weeks of research online. WHEW!
I have Apache set up and understand the different modules, settings, etc....but for the life of me, I can not figure out how the IP based Virtual Hosting works. I have tried many different configurations but nothing is working. Every site, book, or other resource, does it a little different.
My manager is really pressing me to get this going... would anyone be willing to speak to me via phone instead of going back and forth through this forum? If not that's ok...I'm just in a bit of a "pinch".
Thanks
 
If you are using really generic vhosts I suggest mod_vhost_alias. It allows you to have dynamic vhosts based on DNS only. So, you set up the dns to point to this box, create a directory with the name of the domain it is just 'works', no restart required.

So in ths case I have a directory called / In that directory I have other directories like etc etc. Apache, using VirtualDocumentRoot, automatically knows where to route requests based on the domain name.


<VirtualHost 10.0.0.21:80>
UseCanonicalName Off
VirtualDocumentRoot /LogFormat "%V %h %l %u %t \"%r\" %>s %b" vhost_common
CustomLog /var/log/ vhost_common
</VirtualHost>
 
thanks for the info eric and siberian. I currently have it set up as eric's method. Siberian, what is the advantage of using the mod_vhost_alias? Any disadvantages? I may have a few questions about setting it up.
Thanks
 
Advantage : Zero maintenance on the apache side. You just add a domain to dns, add the directory to your root and put your files there. It immediately 'works'.

Disadvantages : Any site that requires custom configuration has to be configured outside of this since its using a single 'template' for all of the sites.

mod_vhost_alias works great in a mass virtual hosting situation where every site has the same basic configuration. As long as you enable .htaccess for the template host you should get all of the flexibility you need.

Personally, my benefit is that it allows my designers and implementors to setup sites on the fly without having to modify apache config files or have system level access. They just set up dns and create their directories. Less work for me! :)



 
I just added my 3rd site to the httpd.conf file and after I did a apachectl graceful, it gave me an error..."[warn] _default_ VirtualHost overlap on port 80, the first has precedence"
I have it set up as in your example above:
<VirtualHost *:80>
ServerAdmin webmaster@cust1.com
ServerAlias cust1.com
ErrorLog /home/cust1/ CustomLog /home/cust1/ combined
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@cust2.com
ServerAlias cust2.com
ErrorLog /home/cust2/ CustomLog /home/cust2/ combined
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@cust3.com
ServerAlias cust3.com
ErrorLog /home/cust3/ CustomLog /home/cust3/ combined
</VirtualHost>

Any suggestions would be appreciated.
 
Does it not work?

If not you probably need to add a NameVirtualHost command to tell apache 'this ip is a vhost'

mod_vhost_alias makes this a bit easier :)

 
Do you have a "NameVirtualHost" directive anywhere in your config? Mine looks like this:

NameVirtualHost *:80

Don't overlook any directory includes.
 
well.....as soon as I un-commented NameVirtualHost *:80, then apache would not run at all. hmmm....??? I commented it back out and removed the other 2 websites and now it is fine again. Just a note....we do not have our own DNS server, it is all routed through Network Solutions...so I do not know how to configure anything with DNS on this box. I would like to keep it as simple as possible.
 
My suggestion is to use an IP instead of the wildcard(*) or delete your default vhost to eliminate the conflict.

 
siberian, are you talking about using an IP for the NameVirtualHost directive or VirtualHost?
Look up at my post, 2 posts above this one, and that is how I would like to set up my httpd.conf file. I started off using IP addresses but ran into difficulty trying to set up the DNS part.

 
I dunno, here is what I do and it works great

NameVirtualHost 10.0.0.1
<VirtualHost 10.0.0.1:80>
ServerAdmin webmaster@cust3.com
ServerAlias cust3.com
ErrorLog /home/cust3/ CustomLog /home/cust3/ combined
</VirtualHost>
<VirtualHost 10.0.0.1:80>
ServerAdmin webmaster@cust2.com
ServerAlias cust2.com
ErrorLog /home/cust2/ CustomLog /home/cust2/ combined
</VirtualHost>

<VirtualHost 10.0.0.1:80>
ServerAdmin webmaster@cust3.com
ServerAlias cust3.com
ErrorLog /home/cust3/ CustomLog /home/cust3/ combined
</VirtualHost>

I used to host about 250-300 domains at any given time using this methodology. I have since migrated it to

NameVirtualHost 10.0.0.1
<VirtualHost 10.0.0.1:80>
UseCanonicalName Off
VirtualDocumentRoot /LogFormat "%V %h %l %u %t \"%r\" %>s %b" vhost_common
CustomLog /var/log/ vhost_common
</VirtualHost>


So, I guess, even from reading above, that I totally do not understand the intersection of IP based virtual hosting and problems with DNS. Your specify the host by IP but its actually the ServerName from the headers that does determination on vhost selection.

I guess I'll go be quiet now. Sorry for the distraction.
 
no...siberian, I appreciate your help, greatly. I am simply trying to get this "monster" going and I am learning as I go. I was given this project to switch our IIS server over to Apache and I have very little knowledge with Apache.
So I stumbled across this forum and have gotten lots of great help.
As you can read from the prior posts, I have been going step by step and trying one thing at a time. The first website that I switched over has been running flawlessly for a week. It is when I went to add the 2nd host that started causing the error: "[warn] _default_ VirtualHost overlap on port 80, the first has precedence". So what you are saying siberian is, doing it your way:

NameVirtualHost 10.0.0.1
<VirtualHost 10.0.0.1:80>
UseCanonicalName Off
VirtualDocumentRoot /LogFormat "%V %h %l %u %t \"%r\" %>s %b" vhost_common
CustomLog /var/log/ vhost_common
</VirtualHost>

requires NOTHING more than just adding this to my httpd.conf file?
I think ALL of my websites are pretty much set up the same so this may work well for me...and it seems simple.
 
Thats how I handle it and it works very well for me, just make sure you have the vhost compiled into the binary or available via DSO and you should be set.

Change the IP and paths of course :)

 
whoa whoa whoa siberian....see? "just make sure you have the vhost compiled into the binary or available via DSO and you should be set" is like speaking another language to me.
I am not sure what you mean by that statement.
I have the bundled version of Apache that comes with RedHat 9 and am simply using the default httpd.conf file(which I hear is pretty good) I am going to head back in to work in about 15 minutes and I will try your method for the 3 existing sites.
Do I need all of this "%V %h %l %u %t \"%r\" %>s %b in the log format
 
siberian,
I just got back from the office. mod_vhost_alias.c is not in the listing. I am a little hesitant RPM a new apache though. I am nervous that something would go wrong. I went to the website and saw that there are alot of dependencies and I am not sure if I have all of them or not.
So I did it the first way that you and eric said, and used the IP instead of the * and it is working so far. I'll keep an eye on it.
I ultimately would love to do it your second way though. It seems much simpler. I just will need to research it a little bit before I do.

 
I was reading on Apache's website and am looking for information on rotating logs. They recommend:

mv access_log access_log.old
mv error_log error_log.old
apachectl graceful
sleep 600
gzip access_log.old error_log.old

Where do I add this? Does it go in httpd.conf in each virtual host container?

They also recommend using the pipe ( | ) command....could you also give details about this also? Which way would you recommend?
 
My personal preference, is to use cronolog. Its awesome.


It lets you autoarchive logs by any directory criteria you want. Using it we have 4 years of log archives sorted on a daily bases in a YYYY/MM/DD structure.

I think there is also a rotatelogs tool included.

Both of these will do log rotation 'on the fly' and not require and automated restart. Automated restarts are 'Bad' since they may not recover and when they don't you may not be around to check.
 
Well...I now have 4 websites added to my httpd.conf file. I can get to them fine inside of our network. Globally, when someone tries to access a website, it directs them to the first VirtualHost. Siberian, I have it set up just like we discussed earlier in this post(from your example):
NameVirtualHost 10.0.0.1
<VirtualHost 10.0.0.1:80>
ServerAdmin webmaster@cust3.com
ServerAlias cust3.com
ErrorLog /home/cust3/ CustomLog /home/cust3/ combined
</VirtualHost>
<VirtualHost 10.0.0.1:80>
ServerAdmin webmaster@cust2.com
ServerAlias cust2.com
ErrorLog /home/cust2/ CustomLog /home/cust2/ combined
</VirtualHost>

<VirtualHost 10.0.0.1:80>
ServerAdmin webmaster@cust3.com
ServerAlias cust3.com
ErrorLog /home/cust3/ CustomLog /home/cust3/ combined
</VirtualHost>

Can you think of anything else that could be set wrong to cause this?
 
when they come through globally is your firewall stripping the servername? What is between you and the global user?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top