Recall & Review
beginner
What does the
add_header directive do in nginx?It adds custom HTTP response headers to the responses sent by the nginx server to clients.
Click to reveal answer
beginner
How do you add a header named
X-Frame-Options with value DENY in nginx?Use the directive: <br>
add_header X-Frame-Options "DENY";Click to reveal answer
intermediate
Where in the nginx configuration file can you place the
add_header directive?You can place it inside
http, server, or location blocks depending on the scope you want the header to apply.Click to reveal answer
intermediate
What happens if you use
add_header inside a location block that overrides a header set in server block?The header set in the
location block will override or add to the headers from the server block for requests matching that location.Click to reveal answer
beginner
Why might you want to add security headers like
Content-Security-Policy using add_header?To improve security by controlling what resources the browser can load, preventing attacks like cross-site scripting (XSS).
Click to reveal answer
Which nginx directive is used to add a custom response header?
✗ Incorrect
The correct directive to add response headers in nginx is
add_header.Where can the
add_header directive be placed in nginx config?✗ Incorrect
The
add_header directive can be used inside http, server, or location blocks.What is the effect of adding
add_header X-Frame-Options "DENY";?✗ Incorrect
The header
X-Frame-Options: DENY prevents the page from being displayed inside frames or iframes.If you want to add a header only for a specific URL path, where should you put the
add_header directive?✗ Incorrect
To add a header only for a specific URL path, place
add_header inside the matching location block.What must you do after changing nginx config to apply new headers?
✗ Incorrect
You must reload or restart nginx to apply configuration changes including new headers.
Explain how to add a custom HTTP response header in nginx and where you can place the directive.
Think about the scope of configuration blocks and the directive syntax.
You got /4 concepts.
Describe why adding security headers with add_header is important and give an example.
Consider how browsers use headers to control page behavior.
You got /4 concepts.