Moderator: igrr
BTW, you didn't mentioned what his your client, is it another ESP or a mobile phone or even a laptop ?
Because the issue isn't on ESP server, it is on the client, so the simplest workaround is to figure out if the client is inside or outside and switch URL accordingly.
EDIT : Oupps ! I've just realized ... your URL is located in a Javascript provided by your ESP ...
Than, the switch can be done there : your ESP need to figure out the RemoteIP and decide which URL need to be sent in the Web page according to either the IP is internal or not ...
websock = new WebSocket('ws://' + window.location.hostname + ':81/');