Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Virtual Hosts & Subdomains

5 views
Skip to first unread message

David Hughes

unread,
Mar 16, 2012, 2:19:32 PM3/16/12
to
Hi all,

Forgive me if this is slightly off-topic, but I wonder if I could
trouble you for some advice about setting up website subdomains with
Apache. I currently have a website up and running on a jailed VPS; I've
been trying to set up subdomains so that one might navigate to a certain
area of the site by using a URL of the form blog.mywebsite.net rather
than mywebsite.net/blog.

I've tried reading the official Apache documentation and a number of
tutorials that I've found online, but nothing I've tried has worked so
far. Do Virtual Hosts behave differently if they're within a jail? Or do
I need some sort of DNS registration for subdomains? I've been trying to
figure it out by myself, with little success so far - I'm quite new to this.

Thanks for your help,

David
_______________________________________________
freebsd-...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questi...@freebsd.org"

Edwin L. Culp W.

unread,
Mar 16, 2012, 2:38:31 PM3/16/12
to
2012/3/16 David Hughes <dghug...@googlemail.com>

> Hi all,
>
> Forgive me if this is slightly off-topic, but I wonder if I could trouble
> you for some advice about setting up website subdomains with Apache. I
> currently have a website up and running on a jailed VPS; I've been trying
> to set up subdomains so that one might navigate to a certain area of the
> site by using a URL of the form blog.mywebsite.net rather than
> mywebsite.net/blog.
>
> I've tried reading the official Apache documentation and a number of
> tutorials that I've found online, but nothing I've tried has worked so far.
> Do Virtual Hosts behave differently if they're within a jail? Or do I need
> some sort of DNS registration for subdomains? I've been trying to figure it
> out by myself, with little success so far - I'm quite new to this.
>

If you have control of your DNS for mywebsite.net just add a CNAME for
blog.mywebsite.net and add a virtual server to your apache configuration.
I'm assuming that you control your DNS and your apache server. More
subdomains would requier repeating the process.

Not much help without a bit more info on your installation.

ed


>
> Thanks for your help,
>
> David
> ______________________________**_________________
> freebsd-...@freebsd.org mailing list
> http://lists.freebsd.org/**mailman/listinfo/freebsd-**questions<http://lists.freebsd.org/mailman/listinfo/freebsd-questions>
> To unsubscribe, send any mail to "freebsd-questions-**
> unsub...@freebsd.org <freebsd-questi...@freebsd.org>"

Alejandro Imass

unread,
Mar 16, 2012, 2:39:18 PM3/16/12
to
On Fri, Mar 16, 2012 at 2:19 PM, David Hughes <dghug...@googlemail.com> wrote:
> Hi all,
>
> Forgive me if this is slightly off-topic, but I wonder if I could trouble
> you for some advice about setting up website subdomains with Apache. I
> currently have a website up and running on a jailed VPS; I've been trying to
> set up subdomains so that one might navigate to a certain area of the site
> by using a URL of the form blog.mywebsite.net rather than
> mywebsite.net/blog.
>
> I've tried reading the official Apache documentation and a number of
> tutorials that I've found online, but nothing I've tried has worked so far.
> Do Virtual Hosts behave differently if they're within a jail? Or do I need
> some sort of DNS registration for subdomains? I've been trying to figure it
> out by myself, with little success so far - I'm quite new to this.

Please specify some more info:

Are you in a FreeBSD Jail and you have a public or private IP bound to the Jail?

Paul Macdonald

unread,
Mar 16, 2012, 2:39:48 PM3/16/12
to
On 16/03/2012 18:19, David Hughes wrote:
> Hi all,
>
> Forgive me if this is slightly off-topic, but I wonder if I could
> trouble you for some advice about setting up website subdomains with
> Apache. I currently have a website up and running on a jailed VPS;
> I've been trying to set up subdomains so that one might navigate to a
> certain area of the site by using a URL of the form blog.mywebsite.net
> rather than mywebsite.net/blog.
>
> I've tried reading the official Apache documentation and a number of
> tutorials that I've found online, but nothing I've tried has worked so
> far. Do Virtual Hosts behave differently if they're within a jail? Or
> do I need some sort of DNS registration for subdomains? I've been
> trying to figure it out by myself, with little success so far - I'm
> quite new to this.
>

If you post a sample virtualhost config people can comment and point out
suggestions.. (there's a couple of ways to do it.)

yes, you need subdomains to have DNS entries ( or hosts file entries at
the least).

Jails will be irrelevant, other than ensuring that the IP for the
virtual host, and the jailed apache is correct/reachable.

Paul.

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


--
-------------------------
Paul Macdonald
IFDNRG Ltd
Web and video hosting
-------------------------
t: 0131 5548070
m: 07970339546<<PLEASE NOTE NEW MOBILE<<
e: pa...@ifdnrg.com
w: http://www.ifdnrg.com
-------------------------
IFDNRG
40 Maritime Street
Edinburgh
EH6 6SA
-------------------------

mikel king

unread,
Mar 16, 2012, 2:27:21 PM3/16/12
to

On Mar 16, 2012, at 2:19 PM, David Hughes wrote:

> Hi all,
>
> Forgive me if this is slightly off-topic, but I wonder if I could trouble you for some advice about setting up website subdomains with Apache. I currently have a website up and running on a jailed VPS; I've been trying to set up subdomains so that one might navigate to a certain area of the site by using a URL of the form blog.mywebsite.net rather than mywebsite.net/blog.
>
> I've tried reading the official Apache documentation and a number of tutorials that I've found online, but nothing I've tried has worked so far. Do Virtual Hosts behave differently if they're within a jail? Or do I need some sort of DNS registration for subdomains? I've been trying to figure it out by myself, with little success so far - I'm quite new to this.
>
> Thanks for your help,
>
> David

You may need to setup namebased virtual hosting.

This article may help point you in the right direction.... http://bit.ly/qUyZQY


Regards,
Mikel King
BSD News Network
http://bsdnews.net
skype: mikel.king
http://twitter.com/mikelking

Robert Bonomi

unread,
Mar 17, 2012, 3:00:39 AM3/17/12
to

David Hughes <dghug...@googlemail.com> wrote
> Hi all,
>
> Forgive me if this is slightly off-topic, but I wonder if I could
> trouble you for some advice about setting up website subdomains with
> Apache. I currently have a website up and running on a jailed VPS; I've
> been trying to set up subdomains so that one might navigate to a certain
> area of the site by using a URL of the form blog.mywebsite.net rather
> than mywebsite.net/blog.
>
> I've tried reading the official Apache documentation and a number of
> tutorials that I've found online, but nothing I've tried has worked so
> far. Do Virtual Hosts behave differently if they're within a jail? Or do
> I need some sort of DNS registration for subdomains? I've been trying to
> figure it out by myself, with little success so far - I'm quite new to this.

This takes several things to make it work.
1) You must have DNS entries for all the various {foo}.domian.tld
paths that you intend to use. CNAMEs that point to domain.tld
will work, combined with an 'A' (and/or 'AAAA') records for the
domin.tld name itself. You'll also need an rDNS record for the
IP address -- that points to domiain.tld .

This stuff is necessary so that a web browser knows how/where to
find the server for {foo}.domiain.tld .

2) then you need to tell Apache that it is to services requests for
multiple domain names. This is what the 'virtualhost' stuff in
the Apache config file does.

3) the web browser *MUST* generate 'HTTP/1.1' queries -- where the
hostname that one is expecting a response from is, itself, included
in the request that is sent to the server at the 'resolved' IP
address.

Alejandro Imass

unread,
Mar 17, 2012, 10:12:10 AM3/17/12
to
On Sat, Mar 17, 2012 at 3:00 AM, Robert Bonomi <bon...@mail.r-bonomi.com> wrote:
>
> David Hughes <dghug...@googlemail.com> wrote
>> Hi all,
>>
[...]

>
> This takes several things to make it work.
>  1) You must have DNS entries for all the various  {foo}.domian.tld

[...]

Yeah, for one, the OP should provide details of his implementation
since as you very well point out there are many places where this can
go wrong... We use a jail that reverse proxies to all other jails.
This allows a 2 layer set-up that is not only more secure, but more
flexible as well.

We still don't know if the OP's jail is bound to a public IP or not...

David Hughes

unread,
Mar 17, 2012, 12:38:07 PM3/17/12
to
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.


Thanks again for all your help, much appreciated.

Best regards,

David

Alejandro Imass

unread,
Mar 18, 2012, 12:02:03 AM3/18/12
to
On Sat, Mar 17, 2012 at 12:38 PM, David Hughes
<dghug...@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
0 new messages