How to have a working HAproxy reverse proxy configuration for Webmin application.

Problem

After configuring HAproxy in front of your Webmin installation the same way you would for a standard web server, you will notice that during the login process your browser tries to connect to port 10000. Which is the default port that Webmin is listening to. It fails for obvious reasons. HAproxy is usually configured to listen to ports 80 and 443. And Webmin is running on internal network, behind a firewall, on port 10000. I’m assuming you already have  a working HAproxy installation in pfSense and your Frontend and Backend are configured correctly. If you want to know how to configure all of that, leave a comment bellow.

Solution

In the “Backend” section for your Webmin service you will need to add the following “Action” to the “Access control lists and actions”: Select “http-response header replace value” from the drop down list. Add the following values name: Locationfind: (.*):.*, and replace: \1

Save these changes and apply configuration. Now your Webmin login should working as expected.

 

Bonus

This solution can be implemented with HAproxy that is installed not on pfSense. Just add this line to the Backend configuration of the HAproxy service.

http-response replace-value Location (.*):.* \1


Enjoy.