0
0
Nginxdevops~20 mins

Proxy headers forwarding in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Proxy Headers Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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;
}
AThe header contains the original client IP plus any existing X-Forwarded-For values.
BThe header contains only the backend server IP address.
CThe header is removed and not sent to the backend.
DThe header contains only the IP address of the Nginx proxy server.
Attempts:
2 left
💡 Hint
Think about how Nginx appends client IPs to the X-Forwarded-For header.
Configuration
intermediate
2: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?
Aproxy_set_header Host $host;
Bproxy_set_header Host $http_host;
Cproxy_set_header Host $proxy_host;
Dproxy_set_header Host $server_name;
Attempts:
2 left
💡 Hint
The original Host header is stored in a variable starting with $http_.
Troubleshoot
advanced
2: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?
AThe proxy_pass directive is missing a trailing slash.
BNginx is not forwarding the Host header correctly.
CThe backend is not reading the X-Forwarded-For header sent by Nginx.
DNginx is caching the responses and not forwarding requests.
Attempts:
2 left
💡 Hint
Think about how backend servers get the real client IP behind proxies.
🔀 Workflow
advanced
3: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.
A4,1,2,3
B3,2,1,4
C2,3,1,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Headers must be set before proxy_pass directive.
Best Practice
expert
3: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?
Aproxy_set_header X-Forwarded-For $remote_addr;
Bproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Cproxy_set_header X-Forwarded-For $http_x_forwarded_for;
Dproxy_set_header X-Forwarded-For '';
Attempts:
2 left
💡 Hint
Consider which variable cannot be spoofed by the client.