Lab Information
We have a backup management application UI hosted on Nautilus's backup server in Stratos DC. That backup management application code is deployed under Apache on the backup server itself, and Nginx is running as a reverse proxy on the same server. Apache and Nginx ports are 8082 and 8092, respectively. We have to install the iptables firewall on the server. Make the appropriate changes to fulfill the requirements mentioned below:
We want to open all incoming connections to Nginx's port and block all incoming connections to Apache's port. Also make sure rules are permanent.
Lab Solutions
π§ Part 1: Lab Step-by-Step Guidelines
1οΈβ£ Login to Backup Server
ssh clint@stbkp01
# Password: H@wk3y3
sudo -i
2οΈβ£ Install iptables
yum install -y iptables
yum install -y iptables-services
3οΈβ£ Check and Fix iptables
systemctl start iptables
systemctl enable iptables
4οΈβ£ Flush existing rules (clean start)
iptables -F
5οΈβ£ Allow Nginx port (8092)
iptables -A INPUT -p tcp --dport 8092 -j ACCEPT
6οΈβ£ Block Apache port (8082)
iptables -A INPUT -p tcp --dport 8082 -j DROP
7οΈβ£ Allow essential traffic (IMPORTANT)
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
8οΈβ£ Save rules (make permanent)
iptables-save > /etc/sysconfig/iptables
systemctl restart iptables
9οΈβ£ Verify rules
iptables -L -n
Output
[root@stbkp01 ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8092
DROP tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8082
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
π§ Part 2: Simple Step-by-Step Explanation (Beginner Friendly)
What this lab is about
You are controlling:
Who can access which service
Current setup
Service Port Purpose
Apache 8082 backend
Nginx 8092 public access
What you need to do
Allow users β Nginx (8092)
Block users β Apache (8082)
Why block Apache?
Nginx acts as reverse proxy
Users should NOT access Apache directly
What iptables does
iptables = firewall tool
Controls network traffic
Rule explanation
1οΈβ£ Allow Nginx
iptables -A INPUT -p tcp --dport 8092 -j ACCEPT
π Means:
Allow incoming traffic on port 8092
2οΈβ£ Block Apache
iptables -A INPUT -p tcp --dport 8082 -j DROP
π Means:
Reject connections to Apache
3οΈβ£ Allow existing connections
ESTABLISHED,RELATED
π Prevents breaking active sessions
4οΈβ£ Allow loopback
lo (localhost)
π Required for internal communication
Final flow
User β Nginx (allowed) β Apache (internal only)
User β Apache (blocked β)
β‘ Key Concept
Firewall = control entry points to your system
π― Key Takeaway
Expose only what is needed, block everything else
Top comments (0)