# Is this possible?



## graudeejs (Jan 23, 2010)

```
+----------------------------------------+
                    |                                        |
example1.com:80 --> | ip: XXX.XXX.XXX.XXX - NAT or something |
                    |                                        |
example2.com:80 --> | jail1: example1.com 192.168.0.1        |
                    | jail2: example2.com 192.168.0.2        |
example3.com:80 --> | jail3: example3.com 192.168.0.3        |
                    |                                        |
                    +----------------------------------------+
```

My head is going to blow-up

or do I have to

```
+-----------------------------------+
                    |                                   |
example1.com:80 --> | ip: XXX.XXX.XXX.1    -DNS         |
                    |                                   |
example2.com:80 --> | jail1: example1.com XXX.XXX.XXX.2 |
                    | jail2: example2.com XXX.XXX.XXX.3 |
example3.com:80 --> | jail3: example3.com XXX.XXX.XXX.4 |
                    |                                   |
                    +-----------------------------------+
```


----------



## Seeker (Jan 23, 2010)

Your first problem, is also a biggest one.
Initial contact with your server. And is of form:

```
public_ip:80
```
And you can't have firewall redirect, as redirects are being made upon *public_ipublic_port* logic and in your case, all three domain have *SAME public port* 80 (http) and *SAME public IP*.
So all 3 domains, would end up redirected, to the same destination.

This can be done with Apache's named virtual hosts

At least port should differ, for each domain to be able to have a firewall redirect.


----------



## graudeejs (Jan 23, 2010)

dam, I thought so


----------



## gilinko (Jan 23, 2010)

It can be done on the same IP if you are using a apache proxy and named virtual hosts on the frontend that forwards the request to the correct jail backend, but there will be some requirements on the jails apache server(and they have to be apache afaik).

Possible, and there will be a performance hit running all this on the same hardware.


----------



## graudeejs (Jan 23, 2010)

gilinko, any more hints.... links... something? please.


EDIT
As I understand we're talking about reverse porxy


----------



## DutchDaemon (Jan 23, 2010)

Yep, something that analyses the Host: header in every http request packet coming in on your public IP's port 80 and determines which backend webserver to pass it on to. Stuff like Apache's proxy module, Squid's reverse proxy functionality, Varnish, Nginx, probably more.


----------



## gilinko (Jan 23, 2010)

killasmurf86 said:
			
		

> gilinko, any more hints.... links... something? please.
> 
> 
> EDIT
> As I understand we're talking about reverse porxy



Sorry about that, here is some more information.

First of all. Read and understand the information before you get started, things can go horribly wrong(tm) otherwise.

Actually the Apache documentation contains the best information that I know of. First start reading about reverse proxies here Apache 2.2 - mod_proxy

In the end what you are looking for is one of the examples in the vhost documentation Apache 2.2 - VirtualHost examples - proxy

And remember that some packaged php software like wordpress and drupal might need a bit more tuning, as they depend on the hostname for creating links(ie turn on this directive)


----------



## gordon@ (Jan 24, 2010)

Assuming example1.com resides on jail1, example2.com on jail2, etc (your ascii art is unclear).

Totally untested but something like this for the Apache config on the XXX.XXX.XXX.XXX instance of Apache:


```
NameVirtualHost *:80

<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://192.168.0.1/
ProxyPassReverse / http://192.168.0.1/
ServerName example1.com
</VirtualHost> 

<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://192.168.0.2/
ProxyPassReverse / http://192.168.0.2/
ServerName example2.com
</VirtualHost> 

<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://192.168.0.3/
ProxyPassReverse / http://192.168.0.3/
ServerName example3.com
</VirtualHost>
```


----------



## dennylin93 (Jan 25, 2010)

Try out www/varnish. It seems to be quite good for reverse proxies.


----------



## Alt (Jan 25, 2010)

You can use www/nginx since its a proxying webserver =)


----------



## gilinko (Jan 25, 2010)

Alt said:
			
		

> You can use www/nginx since its a proxying webserver =)



As is lighttpd(and apache). So it's back to: "use what you know". 

And if I was to learn something more I would go with learn varnish to use with apache and lighttpd, due to the performance hit of running the proxy and backend http server on the same host.


----------

