Have you resolved this? If turning off ufw solves the problem then the only explanation I can think of is that you've got some other rule that's denying access or you have the wrong IP address for your moodle server. Have you run the command
sudo ufw statusto see the full configuration? You can use the command
sudo ufw --force resetto start with a fresh configuration if necessary. You might also want to try simpler versions of the allow command, such as
sudo ufw allow from 123.45.67.8