Challenge - 5 Problems
Proxy Headers 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 proxy header configuration?
Given this Nginx snippet, what will be the value of the
X-Forwarded-For header sent to the backend server?location / {
proxy_pass http://backend;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}Nginx
location / {
proxy_pass http://backend;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}Attempts:
2 left
💡 Hint
Think about how Nginx appends client IPs to the X-Forwarded-For header.
✗ Incorrect
The variable $proxy_add_x_forwarded_for appends the client IP to any existing X-Forwarded-For header, preserving the chain of IPs through proxies.
❓ Configuration
intermediate2:00remaining
Which configuration correctly forwards the Host header to the backend?
You want the backend server to receive the original Host header from the client. Which
proxy_set_header line achieves this?Attempts:
2 left
💡 Hint
The original Host header is stored in a variable starting with $http_.
✗ Incorrect
The variable $http_host contains the original Host header sent by the client, so forwarding it preserves the original domain requested.
❓ Troubleshoot
advanced2:00remaining
Why does the backend see the wrong client IP when using Nginx as a reverse proxy?
You configured Nginx as a reverse proxy but the backend logs show the Nginx server IP instead of the real client IP. Which is the most likely cause?
Attempts:
2 left
💡 Hint
Think about how backend servers get the real client IP behind proxies.
✗ Incorrect
If the backend does not use the X-Forwarded-For header, it will see the proxy server IP as the client IP.
🔀 Workflow
advanced3:00remaining
Order the steps to correctly forward client IP and Host headers in Nginx proxy configuration.
Arrange these configuration steps in the correct order to forward client IP and Host headers to the backend server.
Attempts:
2 left
💡 Hint
Headers must be set before proxy_pass directive.
✗ Incorrect
Nginx processes directives top to bottom; headers must be set before proxy_pass to be forwarded correctly.
✅ Best Practice
expert3:00remaining
Which Nginx configuration snippet best protects against header spoofing when forwarding client IP?
To avoid clients spoofing the X-Forwarded-For header, which configuration is best to ensure the backend receives a trusted client IP?
Attempts:
2 left
💡 Hint
Consider which variable cannot be spoofed by the client.
✗ Incorrect
Using $remote_addr ensures the IP is the immediate client connecting to Nginx, preventing spoofing of X-Forwarded-For by clients.