Forum

proxy question

Fred
30 June 2015, 12:45
Hi Hugo

Let me start by explaing the scenario...

I am building a new system using FreeBSD 10.1.
Inside my FreeBSd server, I will have 1 jail per web domain.
Eg:
jail1: www.mydomain1.com
jail2: www.mydomain2.com
jail3: www.mydomain3.com
...
Each jail will run their own installation of Hiawatha + PHP-FPM

My IP is 1.2.3.4 and at the moment my domains are www.domain1.com, www.domain2.com and www.domain3.com
The DNS returns 1.2.3.4 for all of them.

What my webserver does at the moment is to interpret the request and routes the request based on the domain-name to the correct directory.

At the moment my single webjails route the requests to port 80/443 to 1.2.3.4 by using pf firewall to one single jail.

On the new server, will multiple jail per domain, I can not interpret the domain name and this is why I need a reverse-proxy comes into place.

The reverse-proxy-jail has the IP 1.2.3.4 and routes the requests based on the domain-names to the internal IPs of the jail.

Could you please tell me how this can be achieved?

I hope I haven't made things hard to understand..

Thank you in advance
Fred
Hugo Leisink
30 June 2015, 12:59
The reverse proxy simply needs a configuration in which each virtual host is mentioned with a ReverseProxy setting which forwards the request.
VirtualHost {
Hostname = www.mydomain1.com
...
ReverseProxy .* http[s]://<ip_jail1>/
}

VirtualHost {
Hostname = www.mydomain2.com, www.some_other_domain.com, www.my_shiny_new_domain.com
...
ReverseProxy .* http[s]://<ip_jail2>/
}

...


Make sure to use the IP address of your jails, not the hostname of the website inside that jail. By doing so, you can use multiple hostnames for a virtualhost in your reverse proxy configuration. Best is to carefully read the ReverseProxy part of the manual page to fully understand what it does and how it works.
Fred
30 June 2015, 13:05
Hi Hugo,

So in effect, I could have a jail purely for the Hiawatha proxy.. Is that right?
Will the code bellow be the entire hiawatha.conf content or do I need more info in there?
VirtualHost {
Hostname = www.domain1.com
...
ReverseProxy .* http[s]://<ip_jail1>/
}

VirtualHost {
Hostname = www.domain2.com, www.some_other_domain.com, www.my_shiny_new_domain.com
...
ReverseProxy .* http[s]://<ip_jail2>/
}
...
Hugo Leisink
30 June 2015, 13:31
That's right. Of course, the configuration file needs more like the ServerID, bindings, etc.
This topic has been closed.