Challenge - 5 Problems
IP Access Control Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the effect of this nginx configuration snippet?
Given the following nginx configuration inside a server block, what will happen when a client with IP 192.168.1.10 tries to access the server?
location / {
allow 192.168.1.0/24;
deny all;
}Nginx
location / {
allow 192.168.1.0/24;
deny all;
}Attempts:
2 left
💡 Hint
Remember that nginx processes allow and deny directives in order and stops at the first match.
✗ Incorrect
In nginx, allow and deny directives are checked in order, stopping at the first match. Here, 'allow 192.168.1.0/24' is first and matches the client IP 192.168.1.10, so access is allowed. The later 'deny all' is not evaluated for this client.
❓ Configuration
intermediate2:00remaining
Which nginx configuration denies all IPs except 10.0.0.5?
Select the correct nginx configuration snippet that denies access to all IPs except the single IP 10.0.0.5.
Attempts:
2 left
💡 Hint
The order of allow and deny directives matters in nginx.
✗ Incorrect
In nginx, directives are checked in order. 'allow 10.0.0.5;' first matches and allows that IP, then 'deny all;' denies everyone else. This means only 10.0.0.5 is allowed, all others denied.
❓ Troubleshoot
advanced2:00remaining
Why does this nginx config block all IPs including allowed ones?
You have this nginx config:
But clients from 192.168.1.100 are still denied access. What is the reason?
location /secure {
deny all;
allow 192.168.0.0/16;
}But clients from 192.168.1.100 are still denied access. What is the reason?
Nginx
location /secure {
deny all;
allow 192.168.0.0/16;
}Attempts:
2 left
💡 Hint
Check the order of allow and deny directives and how nginx processes them.
✗ Incorrect
Nginx processes allow and deny directives in order. If 'deny all;' is first, it denies all clients immediately, so the later 'allow' is ignored. The correct order is to put 'allow' first, then 'deny all;' to allow exceptions.
🔀 Workflow
advanced2:00remaining
What is the correct workflow to restrict access to a web app by IP in nginx?
Which sequence of steps correctly describes how to restrict access to a web application by IP address using nginx?
Attempts:
2 left
💡 Hint
Think about safe steps to avoid downtime or errors.
✗ Incorrect
The safe workflow is to edit the config, test syntax with 'nginx -t', then reload nginx to apply changes without downtime. Restarting before editing or skipping syntax test risks errors or downtime.
🧠 Conceptual
expert3:00remaining
What is the effect of combining 'allow' and 'deny' directives with 'satisfy any;' in nginx?
Consider this nginx configuration snippet:
What is the behavior for a client from IP 10.1.1.50?
location / {
satisfy any;
allow 10.1.1.0/24;
deny all;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}What is the behavior for a client from IP 10.1.1.50?
Nginx
location / {
satisfy any;
allow 10.1.1.0/24;
deny all;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}Attempts:
2 left
💡 Hint
'satisfy any;' means only one condition must be met to allow access.
✗ Incorrect
With 'satisfy any;', nginx allows access if either IP allow or auth_basic passes. Since client IP 10.1.1.50 is in allowed subnet, it bypasses password prompt and is allowed immediately.