0
0
Nginxdevops~5 mins

Proxy headers forwarding in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of forwarding headers in an Nginx proxy setup?
Forwarding headers allows the proxy server to pass important client information, like the original IP address and protocol, to the backend server. This helps the backend understand the real client details.
Click to reveal answer
beginner
Which Nginx directive is commonly used to forward the original client IP address to the backend?
The directive proxy_set_header X-Real-IP $remote_addr; forwards the client's IP address to the backend server.
Click to reveal answer
intermediate
What does the X-Forwarded-For header represent in proxy forwarding?
It lists the IP addresses of the client and all proxies the request passed through, helping the backend identify the original client IP even behind multiple proxies.
Click to reveal answer
beginner
How do you forward the original protocol (HTTP or HTTPS) in Nginx proxy headers?
Use proxy_set_header X-Forwarded-Proto $scheme; to forward the protocol used by the client to the backend server.
Click to reveal answer
intermediate
Why is it important to set Host header when proxying requests in Nginx?
Setting proxy_set_header Host $host; ensures the backend server receives the original host requested by the client, which is important for virtual hosting and correct response generation.
Click to reveal answer
Which directive forwards the client's IP address to the backend in Nginx?
Aproxy_set_header X-Real-IP $remote_addr;
Bproxy_pass http://backend;
Clisten 80;
Dserver_name example.com;
What does the header X-Forwarded-For contain?
AThe client's browser type
BOnly the backend server IP
CThe client's IP and all proxy IPs the request passed through
DThe server's hostname
How do you forward the original protocol (HTTP or HTTPS) in Nginx proxy headers?
Aproxy_pass http://backend;
Bproxy_redirect off;
Clisten 443 ssl;
Dproxy_set_header X-Forwarded-Proto $scheme;
Why set the Host header in proxy forwarding?
ATo block unwanted hosts
BTo pass the original requested hostname to the backend
CTo change the backend IP
DTo enable SSL
Which header is NOT typically forwarded by Nginx proxy to preserve client info?
AServer-Timing
BX-Forwarded-For
CX-Forwarded-Proto
DX-Real-IP
Explain why forwarding headers like X-Real-IP and X-Forwarded-For is important in an Nginx proxy setup.
Think about how the backend knows who really made the request.
You got /4 concepts.
    Describe how to configure Nginx to forward the original client IP, protocol, and host headers to the backend server.
    Focus on the proxy_set_header lines needed.
    You got /5 concepts.