I run a virtualized Nextcloud server on my home server and it has its own domain that is forwarded to my home IP. While playing with Nextcloud, I ran across OnlyOffice and setup another virtual server running the OnlyOffice Document Server. The problem that I ran into is that pfSense redirected incoming traffic to my home IP only to the Nextcloud server and I didn’t have a method for forwarding traffic to the OnlyOffice server on its own subdomain. Basically I wanted:
myserver.com -> Nextcloud 10.1.10.10
onlyoffice.myserver.com -> OnlyOffice 10.1.10.11
Since I’m not really an expert on this, I didn’t know that a reverse proxy is what I needed to make this happen. After digging a little I found that pfSense has HAProxy and that can take the incoming traffic to the home IP and analyze if it was intended for myserver.com or onlyoffice.myserver.com and forward it to the correct server on my network.
Forwarding Subdomains in 1&1
I use 1&1 for my web hosting and registering my domain names. They allow 9,999 subdomains which should be enough! If you use a different service, they probably have similar instructions for creating and forwarding subdomains.
Now of you check your DNS at https://www.whatsmydns.net/ you should see the IP you just inputted begin to show. I’ve found that this takes a few minutes to start showing up and some servers can take a few hours to show the correct IP.
If you have any other subdomains, set them up the same way, all pointing to your home server’s IP.
Setting up HAProxy in pfSense
Now that the subdomains are being routed to your firewall, we need to get pfSense to route them to the correct server.
Configuring the Frontend
I defined two Frontends, one for http traffic and one for https traffic. Anything that comes over http is redirected to https and then to whatever backend is defined.
Configuring the Backend
Each server will be defined in Backend and will be where traffic is routed to.
After inputting all your servers you can go under the Stats tab and each server should be listed as green and showing UP. Now go in your browser and try each domain and subdomain and it should take you to each server.