Multiple servers.. vhost, whats wrong?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Multiple servers.. vhost, whats wrong?

Postby da3533 » 19. August 2010 12:48

hey....

i have 2 hostnames created by dyndns.org... s1.server.org and s2.server.org. both pointing to my 1 external ip (89.647.xx.xx)

www.domain1.com has a CNAME WWW record of s1.server.org and www.domain2.com record of s2.server.org

i want domain1 tobe hosted by server 1 which is located at 192.168.1.1 and domain2 to be hosted by server2 @ 192.168.1.2

i need them both to have servers for themselves...

i tried the following:

Code: Select all
NameVirtualHost *
<VirtualHost *>
    ServerName s1.server.org
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://192.168.1.1/
    ProxyPassReverse / http://192.168.1.1/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>
<VirtualHost *>
    ServerName s2.server.org
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://192.168.1.2/
    ProxyPassReverse / http://192.168.1.2/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>



but all it does it use the first part of this file and ignores the rest,... e.g. if i typed in, domain2.com it will direct to 192.168.1.1 when it suppose to go to 192.168.1.2.


whats wrong with code? cant i have multiple proxy?
da3533
 
Posts: 9
Joined: 19. August 2010 12:40

Re: Multiple servers.. vhost, whats wrong?

Postby Nobbie » 19. August 2010 13:35

da3533 wrote:http://www.domain1.com has a CNAME WWW record of s1.server.org and http://www.domain2.com record of s2.server.org


That is useless and does not help for your problem. To resolve the "ServerName" clause in the VirtualHost Directive, the CNAME records of http://www.domain1.com are not used, instead the URL (http://www.domain1.com) as entered into the browser is used. Apache does not know CNAME Records.

So, if you like to enter http://www.domain1.com in order to reach 192.168.1.1 and http://www.domain2.com for 192.168.1.2, you must specify

Code: Select all
ServerName www.domain1.com


and

Code: Select all
ServerName www.domain2.com


in the VIrtualHosts.

The s1.server.org and s2.server.org are not used for that scenario.

The reason, why http://www.domain1.com (as well as http://www.domain2.com) yields 192.168.1.1 is only due to the fact, that always the FIRST VirtualHost is taken by Apache, if none of the ServerName are matching.

Vice verse, for your configuration, you simply have to enter http://s1.server.org for 192.168.1.1 and http://s2.server.org for 192.168.1.2 (http://www.domain1.com and http://www.domain2.com are unknown to your Apache configuration).
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Multiple servers.. vhost, whats wrong?

Postby da3533 » 19. August 2010 14:00

oh,, yes its obvious now... what shall i do ? isnt there a way? i dont mind 1 pc that sorts out where each request will go...

IP --> proxy either to server 1@ 192.168.1.1 or to server 2@ 192.168.1.2


any way? i just cant have 2 ip addresses otherwise i would have purchased an extra one... but i cant..
da3533
 
Posts: 9
Joined: 19. August 2010 12:40

Re: Multiple servers.. vhost, whats wrong?

Postby Nobbie » 19. August 2010 16:22

da3533 wrote:oh,, yes its obvious now... what shall i do ? isnt there a way?


For what?

You did not specify precisely what you are aming at, you can use two different remote servers as shown above. Simply enter s1.server.org or s2.server.org for the desired remote server (192.168.1.1 or 192.168.1.2). That should work just now out of the box.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Multiple servers.. vhost, whats wrong?

Postby da3533 » 19. August 2010 16:48

my problem is that i cant get more than 1 ip address and i have 2 servers. 5 domains will be hosted from server1 and another 5 from server2 ( i dont want 10 to be hosted by 1 server, i need them separate)

i have 2 hostnames s1.server.org and s2.server.org both of which points to my main IP. 80.xx.xx.xx (made by DynDNs.org)

5 of the domains have WWW CNAME records of to serv1.server.org.. so if you go to http://www.mydomain1.com it will be directed to serv1.server.org which resolves to my IP address, as for the other 5 domains, they have WWW CNAME records of to serv2.server.org which also resolves to my IP address.

so my problem is that i need a way to filter the requests coming in. thus, those domains that come from cname WWW records of s1.server.org will be hosted by server @192.168.1.1 and those with cname WWW records of s2.server.org will be hosted my server @192.168.1.2

i thought a proxyreverse would do this..but i dont think it will work for my situation.

basically, for every domain out there that has their CNAME WWW as serv1.server.org, i want them to be hosted by 192.168.1.1 server and those with serv2.server.org to host by 192.168.1.2.

how would you do this?
da3533
 
Posts: 9
Joined: 19. August 2010 12:40

Re: Multiple servers.. vhost, whats wrong?

Postby Nobbie » 19. August 2010 17:02

da3533 wrote: so if you go to http://www.mydomain1.com it will be directed to serv1.server.org which resolves to my IP address, as for the other 5 domains, they have WWW CNAME records of to serv2.server.org which also resolves to my IP address.


Ok, if it is really working that way, why dont you simply replace the ServerName values in your VirtualHost (replace s1.server.org by http://www.domain1.com etc.)? And, if unsure. you also may add an ServerAlias s1.server.org (s2.server.org for http://www.domain2.com etc.)

Finally your configuration will look like:

Code: Select all
NameVirtualHost *
<VirtualHost *>
    ServerName www.domain1.com
    ServerAlias s1.server.org
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://192.168.1.1/
    ProxyPassReverse / http://192.168.1.1/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>
<VirtualHost *>
    ServerName www.domain2.com
    ServerAlias s2.server.org
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://192.168.1.2/
    ProxyPassReverse / http://192.168.1.2/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Multiple servers.. vhost, whats wrong?

Postby da3533 » 19. August 2010 17:16

you ans it right, and its all correct... but, is there a way not to include the domain name everytime.. ? so apache will filter them with the cnames given...

so i should have said this, sorry.

my problem is that i cant get more than 1 ip address and i have 2 servers. domains will be hosted from server1 and from server2 ( i dont want all to be hosted by 1 server, i need them separate)

i have 2 hostnames s1.server.org and s2.server.org both of which points to my main IP. 80.xx.xx.xx (made by DynDNs.org)

i want all domains that have WWW CNAME records of s1.server.org to be hosted by server1@ 192.168.1.1 and all domains that have cname WWW record of s2.server.org to be hosted by server 2@192.168.1.2

so my problem is that i need a way to filter the requests coming in. thus, those domains that come from cname WWW records of s1.server.org will be hosted by server @192.168.1.1 and those with cname WWW records of s2.server.org will be hosted my server @192.168.1.2


basically, for every domain out there that has their CNAME WWW as serv1.server.org, i want them to be hosted by 192.168.1.1 server and those with serv2.server.org to host by 192.168.1.2.

i thought a proxyreverse would do this..but i dont think it will work for my situation.

how would you do this?
da3533
 
Posts: 9
Joined: 19. August 2010 12:40

Re: Multiple servers.. vhost, whats wrong?

Postby BigWetDog » 19. August 2010 17:24

please read this:

http://httpd.apache.org/docs/2.0/mod/co ... servername

it may help you understand.
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Multiple servers.. vhost, whats wrong?

Postby da3533 » 19. August 2010 17:43

i dont get it. it cant be done.. it says it gets the hostname of the domain too..

i have this:

Code: Select all

NameVirtualHost *
<virtualhost *>
ServerAlias s1.server.org
PoxyRequests Off
<proxy *>
   Order deny, allow
Allow from all
</proxy>
ProxyPass / http://192.168.1.1
ProxyPassReverse / http://192.168.1.1
</VirtualHost>
<virtualhost *>
ServerAlias s2.server.org
PoxyRequests Off
<proxy *>
   Order deny, allow
Allow from all
</proxy>
ProxyPass / http://192.168.1.2
ProxyPassReverse / http://192.168.1.2
</VirtualHost>
da3533
 
Posts: 9
Joined: 19. August 2010 12:40

Re: Multiple servers.. vhost, whats wrong?

Postby Nobbie » 19. August 2010 18:17

If you dont follow my advices, you will never succeed. I give up for now, as everything is said what can be said. Good luck!
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Multiple servers.. vhost, whats wrong?

Postby da3533 » 19. August 2010 18:28

your advice didnt solve my problem.
da3533
 
Posts: 9
Joined: 19. August 2010 12:40

Re: Multiple servers.. vhost, whats wrong?

Postby BigWetDog » 19. August 2010 18:35

Okay, perhaps read this:

http://httpd.apache.org/docs/2.0/vhosts ... html#using

nobbie's done all he can for you.

Also, you might try the apache httpd mailing list, since this is an apache specific question. Perhaps someone there can explain it to you.
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Multiple servers.. vhost, whats wrong?

Postby JonB » 19. August 2010 18:53

What's wrong?>

Well we could start with "its probably going to be an incorrect and inadeqate solution no matter which wunderkind, myself included, offered up a software fix that 'might work' ".

If you don't have a fixed IP and have only a router to do forwarding, you already have a problem. Most routers can only forward a single port to ONE internal IP.

Therefore - that ONE IP has to serve all the requests.

The only feasible software way I see is to use ONE server to catch all the requests, and serve as a proxy server (redirector). I think you might have to run your own DNS locally to pull it off, but I can't even think how to fix that -- its just too complex (thus my first statement).

However there is a way to do this - you need a specialized router setup - one that can do packet inspection and analysis. Quite some time ago I had a similar challenge, worked with a BT senior network architect and we settled on a Cisco 4000 series Content Router. (this would be an enormous effort).

Good Luck
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Multiple servers.. vhost, whats wrong?

Postby BigWetDog » 19. August 2010 19:18

updateing the hosts file on each system would work in place of an internal DNS.
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Multiple servers.. vhost, whats wrong?

Postby da3533 » 19. August 2010 21:24

yes but if i got my local dns up and running, what do i do next? where do i put this dns as it can only be accessed locally. how am i suppose to link the domains to this dns..
da3533
 
Posts: 9
Joined: 19. August 2010 12:40

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 102 guests