Secure apache port.
How to secure Apache’s port (8085) using iptables
on the app hosts while allowing access only from a single server.
Step 1: Install iptables
and Dependencies
- Update the system:
bash sudo yum update -y
- Install
iptables
:bash sudo yum install -y iptables-services
Step 2: Configure Firewall Rules
- Check the LBR host’s IP (Replace
LBR_IP
with actual IP):bash sudo iptables -A INPUT -p tcp --dport 8085 -s LBR_IP -j ACCEPT
- Block Everyone Else:
bash sudo iptables -A INPUT -p tcp --dport 8085 -j DROP
Step 3: Save and Persist Rules
- Save the rules:
bash sudo service iptables save
- Enable and Start
iptables
to persist across reboots:bash sudo systemctl enable iptables sudo systemctl start iptables
Step 4: Verify Firewall Rules
- List active rules:
bash sudo iptables -L -n
- Test the firewall by accessing port 8085.
Now, port 8085 is secured, allowing only the LBR host, and rules persist across reboots! 🚀 Let me know if you need any refinements.