0
0
Nginxdevops~5 mins

Proxy headers in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of proxy headers in nginx?
Proxy headers in nginx pass important client information to the backend server, such as the original IP address and protocol, so the backend knows who made the request.
Click to reveal answer
beginner
Which nginx directive sets the original client IP address in proxy headers?
The directive proxy_set_header X-Real-IP $remote_addr; sets the original client IP address in the X-Real-IP header.
Click to reveal answer
intermediate
What does the X-Forwarded-For header represent?
The X-Forwarded-For header lists the IP addresses of the client and any proxies the request passed through, helping the backend identify the original client IP.
Click to reveal answer
intermediate
How do you pass the original protocol (HTTP or HTTPS) to the backend in nginx proxy headers?
Use proxy_set_header X-Forwarded-Proto $scheme; to send the original protocol (http or https) to the backend server.
Click to reveal answer
beginner
Why is it important to set proxy headers correctly in nginx?
Setting proxy headers correctly ensures the backend server receives accurate client info, which is vital for logging, security checks, and generating correct responses.
Click to reveal answer
Which nginx directive sets the client's original IP address in proxy headers?
Aproxy_set_header X-Real-IP $remote_addr;
Bproxy_pass http://backend;
Clisten 80;
Dserver_name example.com;
What does the X-Forwarded-Proto header tell the backend?
AThe client's IP address
BThe request method (GET, POST)
CThe backend server's IP
DThe original protocol used (HTTP or HTTPS)
Why is the X-Forwarded-For header useful?
AIt sets the backend server's IP
BIt lists all IPs the request passed through
CIt changes the request method
DIt sets the server name
Which of these is NOT a typical proxy header set by nginx?
AX-Server-Name
BX-Forwarded-For
CX-Real-IP
DX-Forwarded-Proto
What happens if proxy headers are not set correctly in nginx?
ABackend server crashes
BNginx stops working
CBackend gets wrong client info
DClient IP is hidden from nginx
Explain why proxy headers like X-Real-IP and X-Forwarded-For are important in nginx proxy setups.
Think about how the backend knows who made the request.
You got /3 concepts.
    Describe how to configure nginx to pass the original protocol and client IP to the backend server.
    Look for directives that set headers with $remote_addr and $scheme.
    You got /2 concepts.