The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   Networking (http://hintsforums.macworld.com/forumdisplay.php?f=14)
-   -   Apache working great, but one small problem (http://hintsforums.macworld.com/showthread.php?t=3981)

jeffo 07-11-2002 08:26 PM

here are my virtual hosts
 
NameVirtualHost *
ServerName *

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@ozzieburn.com
DocumentRoot /Users/ozzieburn
ServerName www.ozzieburn.com
ErrorLog /private/etc/httpd/logs/www.ozzieburn.com_error_log
CustomLog /private/etc/httpd/logs/www.ozzieburn.com_access_log common
</VirtualHost>

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@ozzieburn.com
DocumentRoot /Users/ozzieburn
ServerName ozzieburn.com
ErrorLog /private/etc/httpd/logs/ozzieburn.com_error_log
CustomLog /private/etc/httpd/logs/ozzieburn.com_access_log common
</VirtualHost>

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@ozzieburn.com
DocumentRoot /Users/ozzieburn
ServerName coruscant.ozzieburn.com
ErrorLog /private/etc/httpd/logs/coruscant.ozzieburn.com_error_log
CustomLog /private/etc/httpd/logs/coruscant.ozzieburn.com_access_log common
</VirtualHost>

<VirtualHost 192.168.0.4>
#ServerAdmin webmaster@ozzieburn.com
DocumentRoot /var/www/html
ServerName endor.ozzieburn.com
ErrorLog /private/etc/httpd/logs/endor.ozzieburn.com_error_log
CustomLog /private/etc/httpd/logs/endor.ozzieburn.com_access_log common
</VirtualHost>

<VirtualHost 192.168.0.5>
#ServerAdmin webmaster@ozzieburn.com
DocumentRoot /Users/naboo
ServerName naboo.ozzieburn.com
ErrorLog /private/etc/httpd/logs/naboo.ozzieburn.com_error_log
CustomLog /private/etc/httpd/logs/naboo.ozzieburn.com_access_log common
</VirtualHost>

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@ozziebaby.com
DocumentRoot /Users/ozziebaby
ServerName www.ozziebaby.com
ErrorLog /private/etc/httpd/logs/www.ozziebaby.com_error_log
CustomLog /private/etc/httpd/logs/www.ozziebaby.com_access_log common
</VirtualHost>

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@ozziebaby.com
DocumentRoot /Users/ozziebaby
ServerName ozziebaby.com
ErrorLog /private/etc/httpd/logs/ozziebaby.com_error_log
CustomLog /private/etc/httpd/logs/ozziebaby.com_access_log common
</VirtualHost>

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@ozziebaby.com
DocumentRoot /Users/ozziebaby
ServerName coruscant.ozziebaby.com
ErrorLog /private/etc/httpd/logs/coruscant.ozziebaby.com_error_log
CustomLog /private/etc/httpd/logs/coruscant.ozziebaby.com_access_log common
</VirtualHost>

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@bayknoll.org
DocumentRoot /Users/bayknoll
ServerName www.bayknoll.org
ErrorLog /private/etc/httpd/logs/www.bayknoll.org_error_log
CustomLog /private/etc/httpd/logs/www.bayknoll.org_access_log common
</VirtualHost>

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@bayknoll.org
DocumentRoot /Users/bayknoll
ServerName bayknoll.org
ErrorLog /private/etc/httpd/logs/bayknoll.org_error_log
CustomLog /private/etc/httpd/logs/bayknoll.org_access_log common
</VirtualHost>

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@bayknoll.org
DocumentRoot /Users/bayknoll
ServerName coruscant.bayknoll.org
ErrorLog /private/etc/httpd/logs/coruscant.bayknoll.org_error_log
CustomLog /private/etc/httpd/logs/coruscant.bayknoll.org_access_log common
</VirtualHost>

rusty 07-11-2002 10:19 PM

I could be wrong, but given the fact that you have specified IP addresses in your <VirtualHost 192.168.0.4> tags, I think you will want to replace:

NameVirtualHost *
ServerName *

with

NameVirtualHost 192.168.0.3
NameVirtualHost 192.168.0.4
NameVirtualHost 192.168.0.5



Rusty

jeffo 07-12-2002 09:08 AM

most likely
 
That would make sense. I am just flyin by the seat of my pants. This is the first time I have done this type of thing to this extent. The .4 and .5 entries were not working so this is hopefully why. I will add the new changes and let you know.

Thanks
jeffo

jeffo 07-12-2002 10:28 AM

yes and no
 
I have replaced

NameVirtualHost *
ServerName *

with

NameVirtualHost 192.168.0.3
NameVirtualHost 192.168.0.4
NameVirtualHost 192.168.0.5
SeverName *

and this did fix the problemof being able to access the downloadfolder from any of the three domain names and now it is only accessable from the one that i wanted it to be.

You might have noticed though in my virtual host listing in the previous post i have three IPs listed. This was from an experiment that i did not even know if it was possible or not. maybe some of you knowledgable fellows will be able to tell me if i am trying to do something that is not possible.

I have one ip coming into my house and then a router with several computers behind the router. I have two X boxes and a YDL box that i have apache running on all of them. i have set up it set up from the registrar for the domain names to have the three computer names at the same domain name to go to the same ip. for example:

naboo.ozzieburn.com
coruscant.ozzieburn.com
endor.ozzieburn.com

all are going to my IP.

I was trying to get apache on coruscant to separate them to go to the appropriate computer.

naboo and endor are only going to be hit by me so i am not worried about traffic load on coruscant. is this even possible.

jeffo

rusty 07-12-2002 11:31 AM

Let me see if I can touch on a few of these things. Take them for what they're worth:

I believe that your:

SeverName *

is killing you in terms of your Virtual Host setup. As I see it, you should eliminate that line completely. With that line, I believe you are essentially telling apache that ANY server name is a match, and since that ServerName directive is outside of your Virtual Host directives, all hits are being directed to your default site root instead of being processed by the name matches in your Virtual Hosts directives. At worst I believe this will totally negate your Virtual Host setup, and at best I think it will at least cause some problems. I could be wrong.

This documentation will likely be of use to you.


Next, with only one external IP address as you say you have, I can't think of any way to accomplish what your after in terms of routing different domain names to different internal IPs, though that doesn't mean it can't be done. If you really want to direct external traffic to different machines on your internal network, you'd probably have to use non-standard ports in your URLs. (ie: port 80 maps to X box 1, port 6080 maps to X box 2, and port 7080 maps to linux box)


If you were just running one machine as a webserver, I would do it like this:

Have your DNS point all desired domain and hostname permutations to your external IP address (which you've already done).

On your router, map all incoming port 80 traffic to a single box on your internal network. Let's say 192.168.0.3. (I'm not sure if you've already done this or not.)


In httpd.conf,

precede your Virtual Host directives with:

NameVirtualHost *

(but do NOT include ServerName *, as I discussed!)


Then set up virtual hosts with one directive for each differing DocumentRoot:

<VirtualHost *>
#ServerAdmin webmaster@ozzieburn.com
DocumentRoot /Users/ozzieburn
ServerName www.ozzieburn.com
ServerAlias ozzieburn.com coruscant.ozzieburn.com
ErrorLog /private/etc/httpd/logs/www.ozzieburn.com_error_log
CustomLog /private/etc/httpd/logs/www.ozzieburn.com_access_log common
</VirtualHost>

<VirtualHost *>
#ServerAdmin webmaster@ozzieburn.com
DocumentRoot /Users/naboo
ServerName naboo.ozzieburn.com
ErrorLog /private/etc/httpd/logs/naboo.ozzieburn.com_error_log
CustomLog /private/etc/httpd/logs/naboo.ozzieburn.com_access_log common
</VirtualHost>

<VirtualHost *>
#ServerAdmin webmaster@ozziebaby.com
DocumentRoot /Users/ozziebaby
ServerName www.ozziebaby.com
ServerAlias ozziebaby.com coruscant.ozziebaby.com
ErrorLog /private/etc/httpd/logs/www.ozziebaby.com_error_log
CustomLog /private/etc/httpd/logs/www.ozziebaby.com_access_log common
</VirtualHost>

And so on...



Let me know if any of this does or does not make sense.

Rusty

jeffo 07-12-2002 01:05 PM

this seems like a much cleaner way to do it than what i was thinking. thanks. will try when i get home.

jeffo

jeffo 07-19-2002 11:05 AM

sorry about the long delay in the post, i had some other more important stuff come up. I have changed the formatting to the way tha rusty has suggested and i like it alot better since it is so much easier to follow. The only downside that i can see is that i used to have my logs split up so i could see how much www.ozzieburn.com and ozzieburn.com got hit and tht type of thing, but that was actually kind of a pain anyways and was not that important to me so i forgot about it. i have also abandoned trying to have apache reroute some traffic and used different ports since i am the only one that hits the other computers.

jeffo

Jadey 07-22-2002 06:04 PM

Quote:

Originally posted by jeffo
THANK YOU THANK YOU THANK YOU, I am straight but i would kiss ya if i could!
I'm a girl, but that's quite alright, no kiss necessary. :D

I just wanted to mention the ServerAlias feature. If you have 2 domains served out of the identical directory, there's no need to specify a <VirtualHost> for both of them. All you have to do is:

ServerName www.ozzieburn.com
ServerAlias ozzieburn.com

within just one <VirtualHost> :)

jeffo 07-22-2002 11:07 PM

Sorry jadey
 
sorry about that *kisses* for you then. thanks for all your help. just assuming most computer geeks are men.

jeffo 10-07-2002 08:54 PM

virtual host problem
 
ok mly setup has been working great thanks to all the previous help. recently a friend of mine asked me to temporarily host his website while he took his winblows box down to reinstall and test out a couple forms of linux instead of MS OS. His site is up and running great and everything is working great as far as anyone except for me can see. it is logging the hits to his website in the wrong log file and i cannot figure out why. the following is the virtual host for his site on my machine:

<VirtualHost 192.168.0.3>
#ServerAdmin webmaster@crashgraphics.com
DocumentRoot /Users/crash/WebSite
ServerName coruscant.crashgraphics.com
ServerAlias crashgraphics.com www.crashgraphics.com
ErrorLog /private/etc/httpd/logs/crash_error_log
CustomLog /private/etc/httpd/logs/crash_access_log common
<Directory "/Users/*/Sites">
Deny from all
</Directory>
</VirtualHost>

i know someone is going to ask why i renamed the Sites folder to WebSite, so here is the answer. when they were all named Sites, you could type in http://anydomainname.com/~username and hit that users name in all of them, i did not want this. i wanted only one domain name to do that.

when i delete all of the log files and then bounce apache it recreates all of the log files but this domain will not not log into the crash log files that it creates, instead it puts them into my main website log file. i have compared the virtual host entries many, many times and they are to the letter the same. The only thing that i can think of that is not consistent between my three domains and my friends is that i have my entries through the same domain name server and his is through another registrar. would that make a difference?

thanks again in advance
jeffo


All times are GMT -5. The time now is 07:41 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.