Virtual Hosts & Subdomains
ait at p2ee.org
Sun Mar 18 04:02:05 UTC 2012
On Sat, Mar 17, 2012 at 12:38 PM, David Hughes
<dghughes82 at googlemail.com> wrote:
> Hi all,
> thanks very much for your advice.
> To answer your questions:
> It's a FreeBSD jail that I rent from Exonetric, which I've been using for
> experimental / developmental purposes. I haven't registered a personal
> domain name for it - as it's mainly for me to mess about with than for the
> world to see - but it is bound to a public IP and generic domain name
> (http://jail0152.vps.exonetric.net/). I don't have access to the domain name
> that came with the jail - and I think that is probably where the problem
> Here's the current text of my httpd.conf:
> Output of ifconfig:
> I tried adding additional <VirtualHost> entries for subdomains, but it
> didn't work - although I think I understand why that is now.
> Me having this jail is mostly an exercise in learning the whys and
> wherefores of remote Unix[-like] server administration - something tells me
> I need to learn more about the workings of DNS, as I'd never heard of CNAMEs
OK. First of all you should do it correctly and go by the file
distribution of the Apache 2 port.
Stick to pre-defined httpd.conf and just uncomment the virtual host
file towards the end of the file. Then in extras/httpd-vhosts.conf is
where you should configure you vhosts.
Once you go for virtual hosts the everything should be vhosts, you
should not mix-match single httpd settings with vhost settings. From
the on you should use the extra/ httpd and ssl vhosts in separate
files like it's pre-defined in the port.
>From your example I am assuming you want name-based vhost.
Leave the first vhost pointing to something default and safe. Apache
will default to the very first vhost defined if it cannot match a
Realize that vhost is an http 1.1 feature, meaning that the vhost
mapping is resolved by the domain name in the http request. So even
though several domains may map to the same IP, when the request
reaches Apache it will look in it's vhost table and try to match a
domain name defined in one of the vhosts. If it cannot find one it
will default to the first one. This is very confusing and it's always
safe to leave the first one pointing something default, maybe even a
You don't need to use the hoster's provided domain name, in fact you
shouldn't. I suspect you have your own domains so just make them point
to the IP of jail0152.vps.exonetric.net which seems to resolve to
18.104.22.168 So make __your__ domains point to that IP in your DNS (A
I can't seem to find your NameVirtualHost XXXX which is CRUCIAL for
vhosts to work. Another reson to use extra/httpd-vhosts.conf
Each vhost should match the exact definition of the NameVirtualHost
XXXX line so for a line NameVirtualHost *:80 your vhost tags must be
Then just match the domain name with the lines for example:
you can put as many aliases as you want to match. The above will match
even if the user forgot the www
That's about it. If you use the files provided in FBSD it's easy peasy
but if step out the suggested file distribution then you will surely
get into trouble unless you really know what you're doing. The port
maintainer(s) usually get it right so follow the suggested config
post back if you get it working or if you need further help!
> Thanks again for all your help, much appreciated.
> Best regards,
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions