UFW silently doesn’t work on Oracle Cloud - Thomas Bibby

In the middle of setting up an Oracle Cloud compute instance, more specifically an Ampere ARM instance which is available for free. I couldn’t understand why I couldn’t connect with a web browser after installing Apache on Ubuntu.

It turns out that Oracle have disabled UFW on their images. But it’s silently disabled – you can add rules and enable UFW and it seems like everything is working correctly, but it isn’t. You wouldn’t anthropomorphise a lawnmower, indeed. I’ve only myself to blame really.

Solution was to add this line to /etc/iptables/rules.v4:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

And the equivalent for port 443 and IPv6 but I’m still in the middle of trying to get the thing working.

Edit: the relevant line for https is the same as above but with port 433:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT

I think these lines need to be after the line enabling SSH on port 22 – or at least you need to make sure you don’t delete the line with port 22 or you’ll lose SSH access.

After making the changes you need to refresh with:

sudo iptables-restore < /etc/iptables/rules.v4