So first you will need to allow the 3 IP to access the web interface:
sudo -s
ufw allow from 31.3.2.225 to any port 80
ufw allow from 31.3.2.225 to any port 443
Do the same for the two other IP After that you need to remove all other access with:
ufw deny 80/tcp
ufw deny 443/tcp
You can list the rules with:
You can delete them with:
For the change to take place use:
ufw status numbered
ufw delete <rule number>
ufw reload