Following my previous post on how to make your Jamf Pro server public, I gave it a try in my homelab…
Just note that this is only a proof of concept, as there are many reverse proxies, or load balancers, available for a production environment (both hardware as software). (For Load Balancing my clustered Jamf Pro setup, on another test server, I used HAProxy which has Reverse Proxy functionality as well).
An in depth discussion of how I configured my homelab for testing different scenario’s (both Jamf related as more general) might be for another time, but let’s quickly have a high level look at the following setup.
To skip the small talk and go straight to the tutorial on installing Squid on pfSense: click here 🙂
I’m running an ESXI Hypervisor on a HPE Proliant Server behind my home router (a Netgear Nighthawk X10). To separate the virtual environment, from my home network (last thing you want to do is to kill the network the lady of the house is using for streaming Netflix, Interactive TV, Social Media etc… by building and breaking stuff for testing purposes 🙂 ), I configured a virtual switch in ESXI (linked to one of the 2 network ports of the HPE Proliant server), I installed pfSense on a VM, and connected the WAN side of pfSense to the virtual switch in ESXI. Hence the “WAN” side is getting a private IP address in my home network, but still behind the firewall of my Netgear router. Super handy when testing so called “public” servers running on the hypervisor, as my home network can be considered as the public side of the virtual environment. This with pfSense as the firewall/router in between, and a static route between the home network and the virtual IP range behind the pfSense.
So far, whenever I needed to test a “public” service, I opened ports on the pfSense, or moved the server to the DMZ (WAN side), allowing me to test from any device connected to my home wifi. However, when I needed to really make the service reachable from the Internet I also had to enable port forwarding on the Netgear router. This actually worked fine, but except from the fact that I like to avoid punching any holes in the firewall on ports other than 443 and 80, this gave me one big limitation.
While the Netgear X10 is actually packed with a lot more features than the average consumer router, advanced networking features are still limited. Hence port forwarding a specific port to a specific internal server, means that I couldn’t make another server publicly available on the Internet over the same port.
Following my previous post on Jamf Pro and reverse proxy, as well as to give me more flexibility for future projects, I decided to do things differently by using a reverse proxy. This allows me to port forward port 80 and 443 (or any port I need) from the Netgear to the pfSense… and the reverse proxy does the magic to point the traffic to the server I want.
Let’s see how that works:
Install Squid on pfSense:Pre-requisites:
- A (virtual) machine with pfSense (freeBSD) installed
- A WAN interface configured on the pfSense
- A LAN interface configured on the pfSense, most likely a virtual Switch on your hypervisor
Before we can dive into the reverse proxy settings, we first need to install the service in pfSense, and, while there are for sure other proxy tools offering the same functionality, I went for Squid.
To install Squid on pfSense, log into your portal, go to System-Packet Manager-Available Packages and install Squid:

Next, you’ll have to enable the overall Squid proxy service, as the reverse proxy only becomes available if the normal Squid proxy is enabled. Go to Services-Squid Proxy Server

When enabling Squid, it will ask you to configure Local Cache first. For the purpose of this exercise, I left the default settings, but in view of accelerating the performance of the web servers you are configuring reverse proxy for, this is where you would tweak the caching settings for Squid to speed up your website.

Next, we go to Service-Squid Reverse Proxy

First of all, you’ll have to select the interface on which the reverse proxy will listen. Logically, looking at reverse in reverse proxy, this will be the WAN interface of your pfSense. If needed you can add additional proxy IP’s, such as any virtual IP address of your pfSense firewall on which Squid should listen as well.
Below this you will see the options to enable “Squid Reverse HTTP Settings” and “Squid Reverse HTTPS Settings”, where you will define the ports on which both protocols should listen. Apart from more advanced setups, this is most likely going the be the standard ports 80 and 443. However, as usual, ports below 1024 are reserved ports, and Squid will give you an error when trying to save the settings under the General tab.
The error you’ll see (my apologies for omitting to take a screenshot of this specific error) , will tell you to change the value of net.inet.ip.portrange.reservedhigh in System-Advanced-System Tunables to “0”, but I noticed this variable doesn’t exist by default.
Only the net.inet.ip.portrange.first, which is set to 1024, is present by default.
I added the “reservedhigh” variable, but changing the “first” variable works as well. Furthermore, changing the value to “0” removes the reservation of all ports below 1024, but you could actually put 79 if you want to keep everything below 80 reserved.
(442 if only using reverse proxy for HTTPS or 80/443 when changing the “first” variable instead of adding “reservedhigh”).

Once that’s done, don’t forget to restart the Squid daemon (go to Services-Squid Proxy Server and restart squid – restart icon on the top right) and go back to the General tab of your Squid Reverse Proxy Settings.

For HTTP reverse proxy the settings are quite straight forward, just enable the service and add port 80 (or any custom port your clients are connecting to for HTTP).
HTTPS involves a bit more work, as obviously we’ll need a SSL cert for HTTPS to work. This would bring me again a little too far in this post, but, long story short I used the ACME functionality in pfSense to generate a wildcard SSL cert with the Let’s Encrypt Certificate authority.
“Using ACME in pfSense” is on my draft list for upcoming blogposts, so stay tuned for more! However, if you want to use reverse proxy with SSL, you can either import an existing SSL cert in pfSense, or have a look at Let’s Encrypt to learn more. Once you are familiar with how Let’s Encrypt works, have a look at the ACME package you can install in pfSense. The ACME feature in pfSense is really straight forward. It’s even able to use the API of your domain registrar to automatically handle the DNS Challenge to verify ownership of your domain name. Really cool stuff, I promise you!
Once you have your SSL cert ready, you can enable Squid Reverse Proxy over HTTPS.

Next, Squid needs some backend servers, or at least one (Otherwise there is nothing to proxy 🙂 ), and for that we go to the Web Servers tab.

For the purpose of this exercise I installed a Jamf Pro server on a VM (internal side of the pfSense), and just for the fun of it changed the port to 443. Handy when using it for testing… less typing in the URL 🙂

Finally, we need to add some mappings. This will catch and evaluate the URL the client is connecting to, compare it to a list of criteria and link the user to the correct backend web server or peer. In my case here my on-prem Jamf Pro server.
Give your mapping a name and description and select the relevant peer this mapping should be linked to.
Note: You can map to exact URL’s or use regex expression, where “^” and “$” are respectively the beginning and the end of the pattern it should detect in the URL.

Hit save and done!

Or actually, almost! Depending your pfSense firewall settings, you might have to add a Firewall rule to allow incoming traffic on the ports you configured for Reverse Proxy (80/443).

That’s all folks! As always, if you like this post hit the like button, leave a comment, and tell your friends about this blog by using the sharing buttons down below.
Don’t hesitate to make any suggestions, comments or corrections!

Apple ecosystem enthusiast, geek, tech gadget freak, Belgian living in the Netherlands
Manager Technical Support | Jamf
great i have this working, but i need to make runn aceme letsencript to get valid certificate, but in the incoming domain validation squid reverse respond denying the request. the question is how to make squid reverse proxy respond to validate my domain, because it intercept all traffic to 80 port?
Hi Enriluis,
What are you using to run squid?
Are you using a wild card or specific certificate?
Grtz,
TTG
Hi, the configuration did not work as expected. I have posted my questions in slackoverflow, https://stackoverflow.com/questions/54058001/squid-proxy-to-caching-for-accelerated-https-configuration
This did not work for me 🙁
Hi Yuri. What was the issue?
Thanks for the guide, I’m now happily reverse proxying!
1 issue, the “net.inet.ip.portrange.reserverhigh” isn’t correct, it actually needs to be “net.inet.ip.portrange.reservedhigh”
Other than that all good, thanks for the help.
Hi Bill, good catch! I’ll change the typo! Thanks.
Hi TTG,
thanx for the tutorial. It is easy enough to set up the config for squid’s reverse proxy. However, squid keeps returning the wrong certificates to the client. I have 3 subs on my domain, with one IP of course. 1 sub is for the WAN of the router (External FQDN), 2 are for internal websevers. When I connect with a client from the outside I get the message ‘The host name did not match any of the valid hosts for this certificate’. That is, because squid sends the client the certificate for the sub on the WAN, not passing the traffic to the servers on the LAN to retrieve those certificates. Did I oversee some configuration option. I have previously tried HAProxy for the same purpose, but that solution seemed to have the same issue. Any ideas?
Hmm not sure, I should check the setup I did with my Jamf Pro server to see if I did something special.
Hi,
thank you for this elaborate post on the reversed proxy topic.
I found this post after i started to use pf sense with reversed proxy.
Unfortunately i’m having bad luck in setting up the firewall rule for the wan side of things.
Anay chance you’re wliing to share a picture of the settings on the port 80 rule
thanks in advanced
Hi,
I’m trying a similar setup but would you recommend using linux iptables and routing as oppose to pfsense for firewall and routing to my internal web server? I’ll be using Squid for reverse proxy.
Thanks!
Do you have “ACME in pfsense” tutorial ? Pls help
Hi @Bon
Do you have a specific question / issue? The process is quite straight forward, what’s your roadblock?
Have a look here for instanced: https://blog.artooro.com/2017/02/16/quick-easy-lets-encrypt-setup-on-pfsense-using-acme/comment-page-1/#comment-6197
this is my scenario
Internet—- (x.x.x.x-Public IP) Router (192.168.1.1 Private IP) ——–(WAN: 192.168.1.111) PFSENSE ( LAN: 192.168.10.1) —– Server (192.168.10.10 – test.com)
I have some question:
1. because i dont have domain test.com. its just an example. So External FQDN is test.com or something else ?
2. So if i finish your tutorial, when i type 192.168.1.111:80 , i can acess my server, right ?
3. If I can do your tut with no error, the last step i have do is forwarding port 80 192.168.1.111 in my router ?
I am newbie in pf. Thanks for your help.
I don’t really follow you, but let me try.
Internet->test.com->public IP->router->private subnet->pfsense>other subnet where your server lives… more what you want to do no?
1. Your FQDN would be the URL you would use to hit your server from outside your network (public internet), which needs to be poining to you public IP.
2. From where? Inside? From within the 192.168.1.0/24 subnet, yes if pfsense is proxying port 80 to your server 192.168.10.10 on the other 192.168.10.0/24 subnet, you would indeed reach your server via 192.168.1.111
From the internet? No, would be via FQDN / public IP but that would also involve port forwarding towards the pfsense first.
3. Indeed.
I’ve followed the guide from start to finish. Squid fully loads, etc but when I try to navigate to the pages I’ve specified, the browser can’t find the site. Any ideas?
Hi, that’s hard to say. Not a Squid expert but there are too many variables to tell why the proxy would not work. Network design, Squid server, settings…
If it is a new installation, you need to make a WAN firewall rule in order to allow visitor from the WAN side. I followed this guide and it worked just adding a rule.
If it is a new installation, you need to make a WAN firewall rule in order to allow visitor from the WAN side. I followed this guide and it worked just adding a rule.
Hi, I have 3 webserver behind pfsense, one on port 443 -forward->8443, another on port 80 ->8080, the last one is internal only, want all 3 behind port 443 only.
The one a have in port 443->8443 already has a ssl certificate. How can I keep it untouched? cos a external security server uses it for connection validation.
So I want setup port 443 for the last ones with different CA and keep the first one untouched with its CA on webserver as is actually! Is It possible?
Hi Ronaldo, with Squid reverse proxy it will depend what FQDN you are using for each webserver behind the proxy. On Squid you put a SSL Certificate for the fqdn of the reverse proxy/pfsense… For instance a wildcard for the domain. If then your webservers are subdomains all is fine. If not you can disable SSL check for the webservers in Squid but not recommended I’d say.
If you webservers are not on the same domain as the Squid SSL cert, or if that cert does not have alternative domain names, end users will get cert mismatch warnings.
If you want all serves on 443 you’ll need reverse proxy and a cert on the reverse proxy with all fqdn’s of the webservers as SAN on the cert might be an option.
Each webserver would have their own cert… validity of those is another discussion of course.
(Other proxy solutions like nginx might provide other options).
Thank you! Very understandable post. I could repeat it for my https sites!
Hi!
First I want to thank the very practical tutorial, it has worked for me, but I have a question
Since I use free DDNS to point a URL to my public IP, I have limited subdomains, so I want to perform redirects as a subpath, but I’m not getting results
the goal is to do this:
https://dexter-tech.ddns.net/mantis> Mantis Bug tracker running at https://192.168.220.11/ (also do redirect from http to https)
https://dexter-tech.ddns.net/ -> my front webserver (also http)
https://dexter-tech.ddns.net/webmail -> zimbra webmail
https://dexter-tech.ddns.net/erp -> odoo erp
I have already made the configuration of the pfsense (vm in vmware) and the corresponding servers of each application (also vm’s)
the pfSense is in the network segment of my home network and the servers have their own segment (just like in your tutorial), all the incoming traffic from my router (an Arris) is already redirected to the pfsense and it is receiving connections to all the ports according to firewall rules
The questions are:
* Do I have to do a special configuration (like a regular expression?)
* The servers run apache, does this service need any configuration?
Obs: the response of the servers is empty in all cases
Hi, yes you will need to define which exact FQDN or pattern goes to which backend. Regex expression can do indeed. The service running apache in se does not require changes but is subject to what you want the reverse proxy to do, such as terminating ssl or not.
Great tutorial. Once I stopped forgetting checking checkboxes under Mapping and selecting the peer with the mouse, everything started to work fine.
Nice!
Apache2 using mod_proxy is another option. I use that for my reverse proxy setup. I have two servers I allow out side and 4 domains 3 domains are on one server and each has their own ssl cert.
Don’t forget to turn off NAT rules for previous Web servers you may have had in place in the past!
The proxy will take care of the NAT.
Firewalls will still need to be in place though. (so if you disable NAT, be sure to re-enable the firewall)
Thank you for this blog! It has helped me to set my pfSense Reverse Proxy to work with HTTPS, now my HTTPS reverse proxy works as well.
Great explanation of all steps and settings required for pfSense!
Thanks for the feedback! Happy to see this!
Hi
i have pfsense working with https and i need to redirect the connection to be http with internal vm .
any idea plz?