Since you are mentioning WAN (and not LAN):

AFAICS the current Moonlight.sh script will always assume that the machine is on the local network and append .local to the host name. According to the Recalbox wiki, the Moonlight.sh script needs to be modified to work with IPs instead of hostnames. The Moonlight wiki contains an extensive guide for setting up game streaming over the internet. The guide recommends to pair the server while still being on the same network. If this is an option, it is probably easier than modifying Moonlight.sh. Once that's done, you can manually adjust the config files with the public IP of your server and set up the port forwarding if necessary.