Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Mar 2012 00:02:03 -0400
From:      Alejandro Imass <ait@p2ee.org>
To:        David Hughes <dghughes82@googlemail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Virtual Hosts & Subdomains
Message-ID:  <CAHieY7RGTwA8KuR03qChYD8rTUqBw7uFVH_VDJ0vZBPv6XtJGg@mail.gmail.com>
In-Reply-To: <4F64BDEF.3030602@googlemail.com>
References:  <4F64BDEF.3030602@googlemail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Mar 17, 2012 at 12:38 PM, David Hughes
<dghughes82@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
> lies.
>
> Here's the current text of my httpd.conf:
> http://pastebin.com/NSaj8YfS
>
> Output of ifconfig:
>
> http://pastebin.com/Gke651xt
>
>
> 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
> before.
>

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
domain name.

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
404 response.

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
178.250.76.43 So make __your__ domains point to that IP in your DNS (A
records).

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
<VirtualHost *:80>

Then just match the domain name with the lines for example:
ServerName www.yourdomain.com
ServerAlias yourdomain.com

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
structure ;-)

post back if you get it working or if you need further help!

-- 
Alejandro


>
> Thanks again for all your help, much appreciated.
>
> Best regards,
>
> David
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHieY7RGTwA8KuR03qChYD8rTUqBw7uFVH_VDJ0vZBPv6XtJGg>