The only other way to make an endpoint independent device it to run some other reverse proxy in front of your mosquitto and apache2. Modify your HTML code to look at the incoming port and use that and not hardcode ports.
On your reverse proxy filter I'd probably use the http protocol upgrade tag, and route it to 9001, otherwise direct it to 80. You could also check if the port is 80, and do it like you do it now, since you would assume it is local.
You can the reverse proxy on any other port and point weaved to that. The other upside to this is you can now also port forward multiple devices behind one router.
like I said before this is all built into nginx, and moving from apache to niginx is usually trivial.