Virtualmin Nginx behind HAProxy

Dear All,

I am trying to run Virtualmin using Nginx behind a HAProxy load balancer. Unlike Virtualmin using standard Apache, I am unable to get this to work and I am out of clues.

My network setting starts with a pfSense NAT firewall which can run HAProxy. Inside the firewall, I have an Nginx reverse proxy, a Virtualmin server (Debian Jessie) and alternatively an ISPConfig server available. The servers do work and I can freely plug proxies into and out of the chain.

The setting Internet (via pfSense) -> Nginx Reverse Proxy -> Virtualmin does work - both with Apache and Nginx. It does work with the ISPConfig-Server instead of Virtualmin as well.

The setting Internet -> HAProxy -> Nginx Reverse Proxy -> Virtualmin does work also, again independent of picking Apache or Nginx. The same holds for the ISPConfig-Server. Of course, such a long chain of proxies is not my aim.

The Setting Internet -> HAPRroxy -> Virtualmin does work ONLY with Apache, not with Nginx. I did set this up multiple times with the same result. Modifying the above configurations, I only adjust the LAN IP addresses in the proxy chain. As Virtualmin is at the end of the chain, nothing needs to be changed there. Hence, errors are not very likely. The ISPConfig-Server does work.

In the last setting, HAPRoxy gets a 503 error from Virtualmin Nginx. The logs on the Virtualmin server are not very telling, as they are per domain and blank.

My aim is to use Nginx for efficiency reasons. However, at the moment I am unable to do so. Can someone please point me to the right direction?