I have looked all over on google, but came with bits and pieces of knowledge only. I have this situation: with a single IP, I want to host several VPS. Some services, like SSH can go on different ports, making everything easy. But I would like also several apache servers, so they need to be on port 80. I do not care about https, etc. This is also a controlled environment, not reselling, etc which simplifies everything. The only thing I could think of would be to use a proxy that translates: domain A.com goes to 10.0.0.1:80, domain B.com goes to 10.0.0.2:80 (10.0.0.1 and 10.0.0.2 being different VPS) It would be great if someone that has done this would come up with a simple step-by-step so I can understand the process, as nothing on google really covered this from start to a working solution.
how does this work when it comes to the nat part then? let's assume I have two VPS (10.0.0.1 and 10.0.0.2) and each has apache listening to port 80, do I need to fw traffic from port 80 (on the main node) to both VPS and each decides if they want to handle it? assuming my main ip is x.x.x.x, iptables -t nat -A PREROUTING -p TCP -d x.x.x.x --dport 80 -j DNAT --to-destination 10.0.0.1 iptables -t nat -A PREROUTING -p TCP -d x.x.x.x --dport 80 -j DNAT --to-destination 10.0.0.2 is that correct? From what I understand with the virtual host section, you have one apache server listening and then it dispatches the calls toweard the virtual hosts, but in this case we have several unrelated apache hosts, so how does this work?
Hi, may this wiki post will (-> http://wiki.openvz.org/Shared_webhosting )
One way is to use an http proxy, such as pound, lighttpd, apache, nginx. route all your port 80 traffic to VE 1, which runs one of the above. based on the domain, it will proxy the request to VE2, 3, etc depending on which domain is being requested. Doing the IP translation in the kernel is the best, as VE2,3 see the actual request packets fromt he client, but the kernel would need to look at the packet data, such as using iptables layer 7 inspection module. To my knowledge, the iptables modules in the general redhat distros cannot do this, so an http proxy would be my best suggestion. Rick
so, if I take this example: Apache VPS at 10.0.0.1 (a.com) and 10.0.0.2 (b.com) should I create a proxy VPS, let's say at 10.0.0.3, then forward port 80's traffic to it with: ptables -t nat -A PREROUTING -p TCP -d m.y.i.p --dport 80 -j DNAT --to-destination 10.0.0.3 then, set apache (on 10.0.0.3) with: VirtualHost m.y.i.p:80> ServerName a.com RewriteEngine On RewriteRule ^(.*)$ http://10.0.0.1$1 [P] RewriteRule ^(.*)$ http://www.a.com$1 [P] ServerName b.com RewriteEngine On RewriteRule ^(.*)$ http://10.0.0.2$1 [P] RewriteRule ^(.*)$ http://www.b.com$1 [P] Is that correct? Once I get it right, I think I'll write a wiki page about it