Apache Server configuration support - VirtualHosts / Subdomain problem

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > September 2007 > VirtualHosts / Subdomain problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author VirtualHosts / Subdomain problem
Burning_Ranger

2007-09-05, 1:48 pm

I have a domain, let's call it www.example.com

I have set up my primary website on my home PC (Win32 Apache IP
address 192.168.1.64), done all the port forwarding etc and done
everything and it all works fine.

What I want to do now is setup a subdomain so I can create a blog on
the same machine and it will be accessible via wordpress.example.com
from the Internet.


This is what I have at the end of my httpd.conf file.

NameVirtualHost example.com
<VirtualHost example>
ServerName wordpress.example.com
DocumentRoot "E:/wordpress"
</VirtualHost>

also tried

NameVirtualHost 11.22.33.44

<VirtualHost 11.22.33.44>
ServerName wordpress.example.com
DocumentRoot "E:/wordpress"
</VirtualHost>

where 11.22.33.44 is my external static IP, as well as various
combinations of IP addresses and hostnames, but nothing works.

I haven't done anything with DNS records, just the two basic A records
eexist for the main website. Do I need to? Nor have I touched the
hosts file on my PC since I want I want to access my blog subdomain
from the internet to verify it's working.

Any ideas?

Burning_Ranger

2007-09-05, 1:48 pm

On 5 Sep, 15:07, Burning_Ranger <aziz...@googlemail.com> wrote:
> I have a domain, let's call itwww.example.com
>
> I have set up my primary website on my home PC (Win32 Apache IP
> address 192.168.1.64), done all the port forwarding etc and done
> everything and it all works fine.
>
> What I want to do now is setup a subdomain so I can create a blog on
> the same machine and it will be accessible via wordpress.example.com
> from the Internet.
>
> This is what I have at the end of my httpd.conf file.
>
> NameVirtualHost example.com
> <VirtualHost example>
> ServerName wordpress.example.com
> DocumentRoot "E:/wordpress"
> </VirtualHost>
>
> also tried
>
> NameVirtualHost 11.22.33.44
>
> <VirtualHost 11.22.33.44>
> ServerName wordpress.example.com
> DocumentRoot "E:/wordpress"
> </VirtualHost>


Meant to say here:

NameVirtualHost example.com
<VirtualHost example.com>
ServerName wordpress.example.com
DocumentRoot "E:/wordpress"
</VirtualHost>

Davide Bianchi

2007-09-05, 1:48 pm

On 2007-09-05, Burning_Ranger <aziz001@googlemail.com> wrote:
> I have a domain, let's call it www.example.com


Technically, that's not a 'domain' but is a fully defined service...

> NameVirtualHost example.com


><VirtualHost example>


The NameVirtualHost and the VirtualHost need to report the same thing.
So if you have 'example.com' in the first directive the second need to
have 'example.com' as well. But as usual, if you don't mind to have
the virtual host tied to a specific IP, just use '*' to bind to all
the available IP. The default (example) configuration DOES WORK.

> NameVirtualHost 11.22.33.44
>
><VirtualHost 11.22.33.44>


See before. Moreover, if your machine doesn't have that IP address
it won't respond.

> I haven't done anything with DNS records, just the two basic A records
> eexist for the main website. Do I need to?


You need to have resolution for both www.yourdomain.com and
webpress.yourdomain.com.

Davide

--
Oh My God! They Killed init! You Bastards!
-- From a Slashdot.org post
phantom

2007-09-05, 1:48 pm

"Burning_Ranger" <aziz001@googlemail.com> wrote in message
news:1189001220.651508.230660@r29g2000hsg.googlegroups.com...
>I have a domain, let's call it www.example.com
>
> I have set up my primary website on my home PC (Win32 Apache IP
> address 192.168.1.64), done all the port forwarding etc and done
> everything and it all works fine.
>
> What I want to do now is setup a subdomain so I can create a blog on
> the same machine and it will be accessible via wordpress.example.com
> from the Internet.
>
>
> This is what I have at the end of my httpd.conf file.
>
> NameVirtualHost example.com
> <VirtualHost example>
> ServerName wordpress.example.com
> DocumentRoot "E:/wordpress"
> </VirtualHost>
>


But this is only one of the two domains, so not that helpful, if I assume
both your domains are on the same IP, it wants to be more like:

NameVirtualHost 1.2.3.4:80

<VirtualHost 1.2.3.4:80>
ServerName www.example.com
...
</VirtualHost>
<VirtualHost 1.2.3.4:80>
ServerName wordpress.example.com
...
</VirtualHost>

Although the '1.2.3.4:80' could be '*:80' or even '*' depending upon your
setup.


Burning_Ranger

2007-09-05, 1:48 pm

On 5 Sep, 15:13, Davide Bianchi <davideyeahs...@onlyforfun.net> wrote:
>
> You need to have resolution for bothwww.yourdomain.comand
> webpress.yourdomain.com.


Ok I'm using:

NameVirtualHost 87.194.XXX.XXX

<VirtualHost 87.194.XX.XXX>
DocumentRoot "E:/wordpress"
ServerName wordpress.example.com
</VirtualHost>

87.194.XXX.XXX is my public IP. All incoming requests on port 80 are
forwarded to the LAN machine with apache.

Do I need to create a CNAME record for wordpress.example.com?

There are the records I have now:
@ A 87.194.XXX.XXX
wordpress CNAME 87.194.XXX.XXX
www A 87.194.XXX.XXX

It still doesn't work, or do CNAME records take time to propagate?

Davide Bianchi

2007-09-05, 1:48 pm

On 2007-09-05, Burning_Ranger <aziz001@googlemail.com> wrote:
> On 5 Sep, 15:13, Davide Bianchi <davideyeahs...@onlyforfun.net> wrote:
>
> Ok I'm using:
>
> NameVirtualHost 87.194.XXX.XXX
>
><VirtualHost 87.194.XX.XXX>


As said before, just use '*', not a real IP (or a fake one)

And where is the OTHER VirtualHost entry?

> Do I need to create a CNAME record for wordpress.example.com?


Yes.

> There are the records I have now:
> @ A 87.194.XXX.XXX


Well, this should be enough since everything is resolved to that IP.

What exactly do you mean with 'it doesn't work'? What does it do when
you try to access it from the browser?

Davide

--
Sept 25th: Discovered lots of things about Dynamic HTML.
Notably that almost every site attempting to use it is crap.
-- Alan Cox's diary
Burning_Ranger

2007-09-05, 1:48 pm

On 5 Sep, 15:48, Davide Bianchi <davideyeahs...@onlyforfun.net> wrote:
> As said before, just use '*', not a real IP (or a fake one)
>
> And where is the OTHER VirtualHost entry?


This is what I have now:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "E:/apache"
ServerName example.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "E:/wordpress"
ServerName wordpress.example.com
</VirtualHost>

>
> Yes.
>
>
> Well, this should be enough since everything is resolved to that IP.
>
> What exactly do you mean with 'it doesn't work'? What does it do when
> you try to access it from the browser?


It just gives me the usual "cannot display the page (i.e.) / server
not found (firefox)" when I try http://wordpress.example.com/

I'm using the latest WAMP server if that's any clue.. bugger...

Burning_Ranger

2007-09-05, 1:48 pm

On 5 Sep, 15:48, Davide Bianchi <davideyeahs...@onlyforfun.net> wrote:
> As said before, just use '*', not a real IP (or a fake one)
>
> And where is the OTHER VirtualHost entry?


This is what I have now:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "E:/apache"
ServerName example.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "E:/wordpress"
ServerName wordpress.example.com
</VirtualHost>

>
> Yes.
>
>
> Well, this should be enough since everything is resolved to that IP.
>
> What exactly do you mean with 'it doesn't work'? What does it do when
> you try to access it from the browser?


It just gives me the usual "cannot display the page (i.e.) / server
not found (firefox)" when I try http://wordpress.example.com/

I'm using the latest WAMP server if that's any clue.. bugger...

Burning_Ranger

2007-09-05, 1:48 pm

On 5 Sep, 15:48, Davide Bianchi <davideyeahs...@onlyforfun.net> wrote:
> As said before, just use '*', not a real IP (or a fake one)
>
> And where is the OTHER VirtualHost entry?


This is what I have now:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "E:/apache"
ServerName example.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "E:/wordpress"
ServerName wordpress.example.com
</VirtualHost>

>
> Yes.
>
>
> Well, this should be enough since everything is resolved to that IP.
>
> What exactly do you mean with 'it doesn't work'? What does it do when
> you try to access it from the browser?


It just gives me the usual "cannot display the page (i.e.) / server
not found (firefox)" when I try http://wordpress.example.com/

I'm using the latest WAMP server if that's any clue.. bugger...

phantom

2007-09-05, 1:48 pm

"Davide Bianchi" <davideyeahsure@onlyforfun.net> wrote in message
news:slrnfdtgcc.2pm.davideyeahsure@fogg.onlyforfun.net...
> On 2007-09-05, Burning_Ranger <aziz001@googlemail.com> wrote:
>
> Well, this should be enough since everything is resolved to that IP.
>


I don't know what DNS server you use, but for me that would *only* resolve
example.com but not <anything>.example.com.

Adding a wildcard entry like:
* CNAME example.com.

would resolve <anything>.example.com.


Jim Hayter

2007-09-05, 1:48 pm

Burning_Ranger wrote:
> I have a domain, let's call it www.example.com
>
> I have set up my primary website on my home PC (Win32 Apache IP
> address 192.168.1.64), done all the port forwarding etc and done
> everything and it all works fine.
>
> What I want to do now is setup a subdomain so I can create a blog on
> the same machine and it will be accessible via wordpress.example.com
> from the Internet.
>
>
> This is what I have at the end of my httpd.conf file.
>
> NameVirtualHost example.com
> <VirtualHost example>
> ServerName wordpress.example.com
> DocumentRoot "E:/wordpress"
> </VirtualHost>
>
> also tried
>
> NameVirtualHost 11.22.33.44
>
> <VirtualHost 11.22.33.44>
> ServerName wordpress.example.com
> DocumentRoot "E:/wordpress"
> </VirtualHost>
>
> where 11.22.33.44 is my external static IP, as well as various
> combinations of IP addresses and hostnames, but nothing works.
>
> I haven't done anything with DNS records, just the two basic A records
> eexist for the main website. Do I need to? Nor have I touched the
> hosts file on my PC since I want I want to access my blog subdomain
> from the internet to verify it's working.
>
> Any ideas?
>


Are you testing this from the same internal network that the web server
is on? If so, does your router support you using the external IP
address from the internal network? Many do not (you have to put an
entry in the hosts file with the internal address).

You might try testing from outside your network.

Jim
Burning_Ranger

2007-09-05, 1:48 pm

On 5 Sep, 16:36, Jim Hayter <see.reply...@nowhere.invalid> wrote:
> Burning_Ranger wrote:
>
>
>
>
>
>
>
>
>
>
>
> Are you testing this from the same internal network that the web server
> is on? If so, does your router support you using the external IP
> address from the internal network? Many do not (you have to put an
> entry in the hosts file with the internal address).
>
> You might try testing from outside your network.
>
> Jim


Strange thing is if I move the wordpress folder to the E:/apache
folder, and then try to access it internally (after having added the
relevant bit to the hosts file) it works fine. But it doesn't work if
I have the wordpress folder in paraell to the apache htdocs fodler (E:/
apache). It doesn't work at all from outside.

I have tried testing it from outside the network, but no luck (RDPed
into work PC).

Jim Hayter

2007-09-05, 1:48 pm

Burning_Ranger wrote:
> On 5 Sep, 16:36, Jim Hayter <see.reply...@nowhere.invalid> wrote:

snip original post
[vbcol=seagreen]
>
> Strange thing is if I move the wordpress folder to the E:/apache
> folder, and then try to access it internally (after having added the
> relevant bit to the hosts file) it works fine. But it doesn't work if
> I have the wordpress folder in paraell to the apache htdocs fodler (E:/
> apache). It doesn't work at all from outside.
>
> I have tried testing it from outside the network, but no luck (RDPed
> into work PC).
>


If you move the docroot for wordpress outside the E:/apache folder,
perhaps you need a Directory stanza allowing access to it.
phantom

2007-09-05, 1:48 pm

"Burning_Ranger" <aziz001@googlemail.com> wrote in message
news:1189008139.023691.271370@57g2000hsv.googlegroups.com...
> Strange thing is if I move the wordpress folder to the E:/apache
> folder, and then try to access it internally (after having added the
> relevant bit to the hosts file) it works fine. But it doesn't work if
> I have the wordpress folder in paraell to the apache htdocs fodler (E:/
> apache). It doesn't work at all from outside.
>


aha, you might need:

<Directory E:\wordpress\>
order allow,deny
Allow from all
</Directory>



Steve

2007-09-06, 1:36 am

On Wed, 05 Sep 2007 08:06:15 -0700, Burning_Ranger wrote:

> On 5 Sep, 15:48, Davide Bianchi <davideyeahs...@onlyforfun.net> wrote:
>
> This is what I have now:
>
> NameVirtualHost *:80
> <VirtualHost *:80>
> DocumentRoot "E:/apache"
> ServerName example.com
> </VirtualHost>
>
> <VirtualHost *:80>
> DocumentRoot "E:/wordpress"
> ServerName wordpress.example.com
> </VirtualHost>
>
>
> It just gives me the usual "cannot display the page (i.e.) / server
> not found (firefox)" when I try http://wordpress.example.com/
>
> I'm using the latest WAMP server if that's any clue.. bugger...


If you want to resolve both of these correctly, you'll have to use
dns/hosts to resolve the names to your server IP address, but obviously
the results will need to be different depending on whether you're internal
or external. It's pretty easy to do... I think it's called a 'split brain'
dns. As long as the names resolve correctly on the web server - whether
they be to the local or external ip address ( or probably anything else!
), the server will be happy. As long as dns points the name to the correct
IP address for your current location, everything will work.

I use this scenario to let customers test my web development stuff - a
wildcard dns entry globally points them to my adsl router, which forwards
traffic on port 80 to the web server. Internally, my dns server points the
same name to the local 192.168... address, and I can test from my
workstation.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com