1

After creating a new compute instance in oracle cloud with ubuntu as the os, I installed nginx.

Now to open port 80 I tried the commands sudo ufw allow 'Nginx HTTP' and enabled ufw. But still I couldn't access the server on port 80 from the browser. However, if I use the command sudo iptables -I INPUT -p tcp --dport 80 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT, I can access the server on port 80. To make sure this is the case, I recreated new compute instances and tried this out multiple times. From what I understand ufw serves as a simpler interface to the much more complicated iptables.

Is there an explanation as to why this works like this? `

1
  • I would suggest you instead just do sudo ufw allow http instead of requiring 'nginx http' - 'http' is the more generic port 80 and usually works properly. Also, DO NOT mix ufw and straight iptables commands - use one or the other.
    – Thomas Ward
    Apr 9, 2021 at 14:03

1 Answer 1

1

Actually, I kept googling, I found this: Opening port 80 on Oracle Cloud Infrastructure Compute node - Stack Overflow.

From Jason's answer:

I figured it out. The connectivity issue was due to Oracle's default use of iptables on all Oracle-provided images. Literally the very first thing I did when spinning up this instance was check ufw, presuming there were a few firewall restrictions in place. The ufw status was inactive, so I concluded the firewall was locally wide open. Because to my understanding both ufw and iptables look at the netfilter kernel firewall, and because ufw is the de facto (standard?) firewall solution on Ubuntu, I've no idea why they concluded it made sense to use iptables in this fashion. Maybe just to standardize across all images?

I learned about the rules by running:

$ sudo iptables -L

Then I saved the rules to a file so I could add the relevant ones back later:

$ sudo iptables-save > ~/iptables-rules

Then I ran these rules to effectively disable iptables by allowing all traffic through:

$ iptables -P INPUT ACCEPT
$ iptables -P OUTPUT ACCEPT
$ iptables -P FORWARD ACCEPT
$ iptables -F

To clear all iptables rules at once, run this command:

$ iptables --flush

Anyway, hope this helps somebody else out because documentation on the topic is rather sparse.

1
  • This will not explain why UFW doesn't work.
    – Thomas Ward
    Apr 9, 2021 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .