"Switch to Usermin user" not working correctly when both Webmin and Usermin are behind reverse proxies

When I try to use Webmin to switch to a Usermin user, it doesn’t work.

I have both Webmin and Usermin behind Apache reverse proxies. Here is their configuration:

<VirtualHost webmin.xx.xx:80>
	ServerName webmin.xx.xx
	Include notssl.conf
	Redirect temp / https://webmin.xx.xx/
	ErrorLog /var/log/apache2/error.log
	CustomLog /var/log/apache2/access.log combined
</VirtualHost>

<VirtualHost webmin.xx.xx:443>
	ServerName webmin.xx.xx
	Include ssl.conf
	ErrorLog /var/log/apache2/error.log
	CustomLog /var/log/apache2/access.log combined

	SSLProxyEngine on
	ProxyPass / http://localhost:10000/
	ProxyPassReverse / http://webmin.xx.xx:10000/
	ProxyPreserveHost on
	Header edit Location http://webmin.xx.xx:20000 https://usermin.xx.xx
</VirtualHost>

<VirtualHost usermin.xx.xx:80>
	ServerName usermin.xx.xx
	Include notssl.conf
	Redirect temp / https://usermin.xx.xx/
	ErrorLog /var/log/apache2/error.log
	CustomLog /var/log/apache2/access.log combined
</VirtualHost>

<VirtualHost usermin.xx.xx:443>
	ServerName usermin.xx.xx
	Include ssl.conf
	ErrorLog /var/log/apache2/error.log
	CustomLog /var/log/apache2/access.log combined

	SSLProxyEngine on
	ProxyPass / http://localhost:20000/
	ProxyPassReverse / http://usermin.xx.xx:20000/
	ProxyPreserveHost on
	Header edit Location http://usermin.xx.xx:10000 https://webmin.xx.xx
</VirtualHost>

Webmin & Usermin are both configured to not use SSL, but are blocked behind ufw, so only Apache can communicate with them. Apache uses its own TLS certificates. Webmin and Usermin are both fully functional and there are no issues using them individually (as far as I can tell).

The issue arises when I go to the Usermin Configuration -> Current Login Sessions module and attempt to use “Switch to Usermin user”. When I click the “Switch” button, a new session is created but a new tab opens to the Usermin login page - not to that session.

Am I doing something wrong or is this a bug in Webmin?

Also sometimes trying to switch causes Usermin to refuse to serve any requests until it’s restarted, even though the service is still running.