httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matt farey <matt.fa...@gmail.com>
Subject Re: [users@httpd] setting up virtual hosting
Date Wed, 21 Feb 2007 03:00:33 GMT




Sam Carleton wrote:
> I am pulling my hair out trying to get the virtual hosting working on
> my internal web server.  I need to get a test site online and I would
> like to have it setup as a name based virtual host.  I am running
> Apache v2.2.3 with default layout of SUSE, which consists of the main
> conf file including a bunch of other files.
>
> The virtual host is working just fine, it is the default that isn't
> work!  I have added ServerName which was not there originially to
> this:
>
> ServerName internal.miltonstreet.com
>
> And then I have this for the virtual host:
>
> <VirtualHost _default_:80>
>
>    ServerName      webdev.miltonstreet.com
>    DocumentRoot    "/http/www/webdev.miltonstreet.com"
>
>    ErrorLog /var/log/apache2/webdev.miltonstreet.com-error_log
>    CustomLog /var/log/apache2/webdev.miltonstreet.com-access_log combined
>
>    <Directory "/http/www/webdev.miltonstreet.com">
>        Options Indexes FollowSymLinks
>        AllowOverride None
>        Order allow,deny
>        Allow from all
>    </Directory>
>
> </VirtualHost>
>
> I do *NOT* have a NameVirtualHost directive.
>
> I do have this setup, where the default is *NOT* working either:
>
> <VirtualHost *:443>
>    DocumentRoot "/srv/www/htdocs"
> </VirtualHost>
>
> <VirtualHost secure.miltonstreet.com:443>
>
>    ServerName secure.miltonstreet.com
>
> <\VirtualHost>
>
> What am I missing?
>
> Sam
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


is that what you really want, whenever someone requests your server by
its IP you want to serve them that site?

I usually set up all domains I want by name, and then stick in default
to catch those that use the IP, and just shove them somewhere
unimportant. If they dont use the host header, they are probably not the
type I want anyway. The default goes in the main httpd.conf in case I
need to comment out the vhosts for some reason.

so heres my $0.02 (someone will tell me Im dead wrong I bet but I use
Mass Virtual Hosting for hunderds of sites)

Also not sure why you say you dont have the NameVirtualHost directive,
that needs to be there.

NameVirtualHost 10.10.10.10:80
#---------goes inside httpd.conf
<VirtualHost _default_:80>
ServerName _default_
#etc stuff that you don't care about
</VirtualHost>

#-goes inside httpd-vhosts.conf
<VirtualHost webdev.miltonstreet.com:80>
   ServerName      webdev.miltonstreet.com
   DocumentRoot    "/http/www/webdev.miltonstreet.com"
   ErrorLog /var/log/apache2/webdev.miltonstreet.com-error_log
   CustomLog /var/log/apache2/webdev.miltonstreet.com-access_log combined
   <Directory "/http/www/webdev.miltonstreet.com">
       Options Indexes FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
   </Directory>
</VirtualHost>
<VirtualHost webdev2.miltonstreet.com:80>
   ServerName      webdev2.miltonstreet.com
   DocumentRoot    "/http/www/webdev2.miltonstreet.com"
   ErrorLog /var/log/apache2/webdev2.miltonstreet.com-error_log
   CustomLog /var/log/apache2/webdev2.miltonstreet.com-access_log combined
   <Directory "/http/www/webdev2.miltonstreet.com">
       Options Indexes FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
   </Directory>
</VirtualHost>
#........


Now you should know that without the _default_ virtualhost the first of
these two vhosts will be served up, that is
webdev.miltonstreet.com if nothing else matches, so _default_ can be
thought of as a catch all that can go anywhere in any conf file and be
the one served up when nothing matches, but if you comment it out, which
ever vhosts is defined first will be served in nothing matches,


Are you on a lan, make sure that your hosts file are setup to point
webdev.miltonstreet.com to the correct IP
10.10.10.10 webdev.miltonstreet.com
in the example above.


That way everyone outside will be port forwarded from your public to the
internal IP, however if you request a server from inside you will go
straight to the private IP, rather than being directed by the public DNS
to the public IP which will cause you trouble.



Apologies if you really did want to serve a site when the IP is
requested, but usually this is not want people want as it messes up all
your cookies and so on.



-- 
Matthew Farey


Mime
View raw message