0
0
Nginxdevops~5 mins

proxy_pass directive in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the proxy_pass directive in nginx?
The proxy_pass directive tells nginx to forward client requests to another server or service, acting as a middleman to pass requests and responses.
Click to reveal answer
beginner
How do you use proxy_pass to forward requests to http://localhost:8080?
Inside an nginx location block, write: <br>
proxy_pass http://localhost:8080;
This sends matching requests to the server running on port 8080 on the same machine.
Click to reveal answer
intermediate
What happens if you omit the trailing slash in proxy_pass URL?
If the URL in proxy_pass does not end with a slash, nginx replaces the matching part of the request URI with the URL path. This can change the request path sent to the backend.
Click to reveal answer
beginner
Can proxy_pass be used to forward requests to an HTTPS backend?
Yes, you can use proxy_pass https://backend-server; to forward requests securely to an HTTPS backend server.
Click to reveal answer
intermediate
What directive is commonly used with proxy_pass to set the original host header?
The directive proxy_set_header Host $host; is often used with proxy_pass to pass the original host header to the backend server.
Click to reveal answer
What does the proxy_pass directive do in nginx?
AForwards client requests to another server
BBlocks client requests
CCaches static files
DStarts the nginx server
Which of the following is a correct proxy_pass usage to forward to http://example.com?
Aproxy_pass http://example.com;
Bproxy_pass example.com;
Cproxy_pass https://example.com
Dproxy_pass //example.com;
What is the effect of adding a trailing slash to the URL in proxy_pass?
AIt disables proxying
BIt changes how the request URI is forwarded
CIt enables caching
DIt restarts nginx
Can proxy_pass forward requests to an HTTPS backend?
AOnly if SSL is disabled
BNo, only HTTP backends are supported
CYes, by specifying <code>https://</code> in the URL
DOnly with extra modules
Which directive is used to pass the original host header to the backend when using proxy_pass?
Aproxy_cache on;
Bproxy_redirect off;
Cproxy_buffering off;
Dproxy_set_header Host $host;
Explain how the proxy_pass directive works in nginx and why it is useful.
Think about nginx acting like a middleman between clients and backend servers.
You got /4 concepts.
    Describe the difference in behavior when using a trailing slash versus no trailing slash in the proxy_pass URL.
    Focus on how nginx changes the request path sent to the backend.
    You got /4 concepts.