Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Name-based Virtual Hosts :( |
|
Author |
|
b00x
Joined: 13 Apr 2006 Posts: 3
|
Posted: Thu 07 Sep '06 10:34 Post subject: Name-based Virtual Hosts :( |
|
|
Hi,
I have a bit of a problem with Name-based virtual hosts for Apache 2, and I can't figure it out, I've been over the documentation several times, with no success.
Below is the best configuration I could come up with, but it's still not working as planned, I'll explain after.
-----
NameVirtualHost *:80
NameVirtualHost *:443
NameVirtualHost ##2##.infinita.org:80
NameVirtualHost ##2##.infinita.org:443
<VirtualHost *:80>
DocumentRoot D:/Sithellaneous/Programming/PHP/wwwroot/public
ServerName ##1##.infinita.org
</VirtualHost>
<VirtualHost *:443>
DocumentRoot D:/Sithellaneous/Programming/PHP/wwwroot/secure
ServerName ##1##.infinita.org
</VirtualHost>
<VirtualHost ##2##:80 ##2##.infinita.org:80>
ProxyPreserveHost On
ProxyPass / http://10.1.1.5/
ProxyPassReverse / http://10.1.1.5/
ServerName ##2##.infinita.org
</VirtualHost>
<VirtualHost ##2##:443 ##2##.infinita.org:443>
ProxyPreserveHost On
ProxyPass / https://10.1.1.5/
ProxyPassReverse / https://10.1.1.5/
ServerName ##2##.infinita.org
</VirtualHost>
-----
What i'm trying to do (which may be obvious to some of you), is forward all traffic with a different hostname (##2##.infinita.org) to another machine on my LAN. I've tried mapping a network drive, and i've tried the Proxy option - with no success. The one above however appears to produce the best looking output from a `httpd -S` (found below).
-----
C:\Program Files\Apache2\bin>httpd.exe -S
VirtualHost configuration:
10.1.1.5:80 ##2##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:42)
10.1.1.5:443 ##2##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:4
210.84.10.52:80 is a NameVirtualHost
default server ##2##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:42)
port 80 namevhost ##2##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:42)
210.84.10.52:443 is a NameVirtualHost
default server ##2##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:4
port 443 namevhost ##2##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:4
wildcard NameVirtualHosts and _default_ servers:
*:443 is a NameVirtualHost
default server ##1##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:3
port 443 namevhost ##1##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:3
port 443 namevhost localhost (C:/Program Files/Apache2/conf/extra/httpd-ssl.conf:74)
*:80 is a NameVirtualHost
default server ##1##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:34)
port 80 namevhost ##1##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:34)
Syntax OK
C:\Program Files\Apache2\bin>
-----
Can anyone help me out?
I've hashed out my domain as I don't want it listed on the net, but i've numbered them to differentiate . You might notice a repeat aswell, this is because the sub-domain names match the names of my PC's on my LAN, I don't think this should be a problem, but [shrugs] maybe it is?
Regards,
Corey... |
|
Back to top |
|
Jorge
Joined: 12 Mar 2006 Posts: 376 Location: Belgium
|
Posted: Thu 07 Sep '06 16:05 Post subject: |
|
|
Haven't tested this but try:
Code: |
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost _default_:80>
DocumentRoot D:/Sithellaneous/Programming/PHP/wwwroot/public
ServerName ##1##.infinita.org
</VirtualHost>
<VirtualHost _default_:443>
DocumentRoot D:/Sithellaneous/Programming/PHP/wwwroot/secure
ServerName ##1##.infinita.org
</VirtualHost>
<VirtualHost domain2.com:80>
ProxyPreserveHost On
ProxyPass / http://10.1.1.5/
ProxyPassReverse / http://10.1.1.5/
ServerName domain2.com
</VirtualHost>
<VirtualHost domain2.com:443>
ProxyPreserveHost On
ProxyPass / https://10.1.1.5/
ProxyPassReverse / https://10.1.1.5/
ServerName domain2.com
</VirtualHost>
|
If no matching vhost is found, apache will use _default_
do note that named virtualhosting doesn't work with SSL, unless you have a global cert for all domains. |
|
Back to top |
|
b00x
Joined: 13 Apr 2006 Posts: 3
|
Posted: Fri 08 Sep '06 10:20 Post subject: |
|
|
Hmm, looks good in theory, but I tried it, and it seems apache is taking the 'default' too far... Both my domains are still loading from the first machine, its ignoring my proxy to 10.1.1.5.
I'll show you the `httpd -S` output:
-----
VirtualHost configuration:
210.84.10.52:80 ##2##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:34)
210.84.10.52:443 ##2##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:40)
wildcard NameVirtualHosts and _default_ servers:
*:443 is a NameVirtualHost
default server ##1##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:30)
port 443 namevhost ##1##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:30)
port 443 namevhost localhost (C:/Program Files/Apache2/conf/extra/httpd-ssl.conf:74)
*:80 is a NameVirtualHost
default server ##1##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:26)
port 80 namevhost ##1##.infinita.org (C:/Program Files/Apache2/conf/extra/httpd-vhosts.conf:26)
Syntax OK
-----
So it thinks its doing the right thing, but not
And it seems I'll need to fix up my httpd-ssl.conf file too :\ Don't want those duplicates
[sigh] back to the drawing board
Thanks Jorge. |
|
Back to top |
|
wew-1
Joined: 11 Sep 2006 Posts: 2
|
Posted: Thu 14 Sep '06 17:37 Post subject: Router solution |
|
|
My low end network router will pass traffic to an ip or machine |
|
Back to top |
|
b00x
Joined: 13 Apr 2006 Posts: 3
|
Posted: Fri 15 Sep '06 1:42 Post subject: RE: Router solution |
|
|
Hmm, so does mine, but I'd like to use the same port for all HTTP traffic, and forward traffic to the correct machine based on 'internet' hostname.
[ponders]
I guess it would be nice if my router did hostname based redirection. I'll look into it anyway after work |
|
Back to top |
|
|
|
|
|
|