For your own security, sometimes we want to filter all incoming traffic to our machine and let it go to only some specified ports. We can do it easily using IPTables.

Here is the simple command, which will DROP all incoming traffic to all ports excepting 80,443 (HTTP):
iptables -A INPUT -p tcp -m tcp -m multiport ! --dports 80,443 -j DROP

List of common used ports is here.

Remember to allow yourself to connect to SSH port :)