Skip to content

How to block HTTP/HTTPS access from inside AWS Linux instance?

0

Hi, I have tried so far to modify both the active EC2 Instances "Security Goup" and VPC's active "ACL"s - and still all my AWS Linux instances Firefox browsers have access to Internet (HTTP/HTTPS). How do I block that?

  1. Security Group: does not include ports 80/443 in Incoming rules
  2. VPC ACLs: include a "Block" rule for both 80/443 for both Incoming and Outgoing traffic
  3. RedHat Linux Firewall in the instances are disabled (don't want to manage that) Any help / advice will be appreciated!
asked a year ago670 views
1 Answer
2

You can block outbound connections to the TCP ports 80 and 443 either by not allowing them in the outbound rules of any of the security groups attached to the network interfaces of your EC2 instances, or by explicitly denying traffic to those destinations in the outbound rules of the network ACL (NACL) attached to the subnet(s) hosting your EC2 instances.

If you write a "deny" rule in a NACL, you'll need to give it a rule number less than any other rule that would allow the traffic. For example, if all traffic is allowed by rule 100, the deny rule would have to have a number no higher than 99. To avoid blocking traffic inside your VPC, you might want to allow all traffic to the VPC's CIDR range in a lower-numbered rule, such as 50, and then block the specific port numbers in the next rule, such as 60, before hitting the default rule 100 that allows everything, as an example.

Note that most AWS services, such as S3, DynamoDB, SQS, and many others have their APIs on the standard HTTPS port tcp/443. If you block all outbound HTTPS traffic to the internet, also traffic to all public AWS APIs will be blocked, unless you have local VPC endpoints for those services inside your VPC's CIDR blocks.

EXPERT
answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
  • Thank you for your answer! It did work (I was wrong on inbound/outbound). Wish it allowed us to block ports in Outbound rules as opposed to having to describe add all allowed ports. Thank you for the quick response!

  • NACLS allow explicit "deny" rules to be configured to accomplish that, but NACLs are stateless, processing traffic packet-by-packet, and apply to the whole subnet, making them relatively difficult to use. Security groups indeed don't allow explicit deny rules, so the inverse must be allowed, unfortunately.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.