0
0
Nginxdevops~10 mins

Proxy headers in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the original client's IP address in the proxy headers.

Nginx
proxy_set_header X-Real-IP [1];
Drag options to blanks, or click blank then click option'
A$http_user_agent
B$host
C$remote_addr
D$server_addr
Attempts:
3 left
💡 Hint
Common Mistakes
Using $host instead of $remote_addr causes the backend to see the server's hostname, not the client IP.
Using $server_addr sends the server's IP, not the client's.
2fill in blank
medium

Complete the code to forward the original Host header to the backend server.

Nginx
proxy_set_header Host [1];
Drag options to blanks, or click blank then click option'
A$host
B$remote_addr
C$server_name
D$http_referer
Attempts:
3 left
💡 Hint
Common Mistakes
Using $remote_addr sends the client IP instead of the host.
Using $server_name sends the server's configured name, not the client's requested host.
3fill in blank
hard

Fix the error in the code to correctly set the X-Forwarded-For header to include the client IP and existing forwarded IPs.

Nginx
proxy_set_header X-Forwarded-For [1];
Drag options to blanks, or click blank then click option'
A$http_x_forwarded_for
B$server_addr
C$remote_addr
D$proxy_add_x_forwarded_for
Attempts:
3 left
💡 Hint
Common Mistakes
Using $remote_addr overwrites the existing forwarded IPs.
Using $http_x_forwarded_for alone does not add the current client IP.
4fill in blank
hard

Fill both blanks to set headers that forward the original protocol and client IP to the backend.

Nginx
proxy_set_header X-Forwarded-Proto [1];
proxy_set_header X-Real-IP [2];
Drag options to blanks, or click blank then click option'
A$scheme
B$remote_addr
C$host
D$server_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using $host for X-Forwarded-Proto is incorrect.
Using $server_name for X-Real-IP sends the server name, not client IP.
5fill in blank
hard

Fill all three blanks to set headers that forward the original host, protocol, and client IP to the backend.

Nginx
proxy_set_header Host [1];
proxy_set_header X-Forwarded-Proto [2];
proxy_set_header X-Real-IP [3];
Drag options to blanks, or click blank then click option'
A$remote_addr
B$scheme
C$host
D$server_name
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up $server_name and $host.
Using $remote_addr for Host header.
Using $host for X-Real-IP.