gRPC proxying is when NGINX acts as a middleman that forwards gRPC requests from clients to backend gRPC servers, allowing load balancing, security, and routing.
Click to reveal answer
beginner
Which NGINX directive enables gRPC proxying?
The directive grpc_pass is used inside a location block to forward gRPC requests to a backend gRPC server.
Click to reveal answer
beginner
How do you configure NGINX to listen for gRPC traffic on port 50051?
Use listen 50051 http2; in the server block because gRPC requires HTTP/2 protocol.
Click to reveal answer
intermediate
Why must NGINX use HTTP/2 when proxying gRPC?
Because gRPC uses HTTP/2 for its communication, NGINX must support HTTP/2 to correctly forward gRPC requests and responses.
Click to reveal answer
intermediate
What is the minimal NGINX location block to proxy gRPC requests to backend at grpc://localhost:50052?
location / {
grpc_pass grpc://localhost:50052;
}
This forwards all gRPC requests to the backend server running on port 50052.
Click to reveal answer
Which protocol must NGINX use to proxy gRPC traffic?
AHTTP/2
BHTTP/1.1
CTCP
DUDP
✗ Incorrect
gRPC requires HTTP/2 protocol for communication, so NGINX must use HTTP/2 to proxy gRPC traffic.
What directive in NGINX config forwards gRPC requests to a backend server?
Aproxy_pass
Bgrpc_pass
Cfastcgi_pass
Duwsgi_pass
✗ Incorrect
The grpc_pass directive is specifically designed to forward gRPC requests.
How do you enable HTTP/2 on port 443 in NGINX for gRPC proxying?
Alisten 443;
Blisten 443 ssl;
Clisten 443 http1.1 ssl;
Dlisten 443 http2 ssl;
✗ Incorrect
To support gRPC over TLS, NGINX must listen with HTTP/2 and SSL enabled using listen 443 http2 ssl;.
What happens if NGINX listens without HTTP/2 for gRPC traffic?
ANGINX falls back to HTTP/1.1
BgRPC requests work normally
CgRPC requests fail because HTTP/2 is required
DNGINX automatically upgrades to HTTP/2
✗ Incorrect
gRPC requires HTTP/2; without it, requests will fail because the protocol is not supported.
Which of these is a valid gRPC backend URL in NGINX config?
Agrpc://127.0.0.1:50051
Bhttp://127.0.0.1:50051
Chttps://127.0.0.1:50051
Dtcp://127.0.0.1:50051
✗ Incorrect
The grpc:// scheme is used to specify a gRPC backend in NGINX.
Explain how to configure NGINX to proxy gRPC requests including the necessary directives and protocol requirements.
Think about how NGINX handles HTTP/2 and the grpc_pass directive.
You got /4 concepts.
Describe why HTTP/2 is essential for gRPC proxying and what happens if it is not enabled in NGINX.
Consider the protocol requirements of gRPC.
You got /3 concepts.
Practice
(1/5)
1. What directive in nginx is used to forward gRPC requests to a backend server?
easy
A. fastcgi_pass
B. proxy_pass
C. grpc_pass
D. uwsgi_pass
Solution
Step 1: Understand gRPC proxying in nginx
nginx uses a special directive to forward gRPC calls to backend servers.
Step 2: Identify the correct directive
The directive grpc_pass is specifically designed for gRPC proxying, unlike proxy_pass which is for HTTP, or others for different protocols.
2. Which of the following is the correct syntax to proxy gRPC traffic to a backend at 127.0.0.1:50051 in nginx?
easy
A. grpc_pass grpc://127.0.0.1:50051;
B. grpc_pass http://127.0.0.1:50051;
C. proxy_pass grpc://127.0.0.1:50051;
D. proxy_pass http://127.0.0.1:50051;
Solution
Step 1: Recognize correct protocol prefix for grpc_pass
The grpc_pass directive requires the backend address to start with grpc:// or grpcs:// for secure connections.
Step 2: Match syntax with correct directive and protocol
grpc_pass grpc://127.0.0.1:50051; uses grpc_pass grpc://127.0.0.1:50051; which is the correct syntax. Options A and D use http:// which is incorrect for gRPC. proxy_pass grpc://127.0.0.1:50051; uses proxy_pass which is not for gRPC.
Final Answer:
grpc_pass grpc://127.0.0.1:50051; -> Option A
Quick Check:
grpc_pass + grpc:// = correct syntax [OK]
Hint: Use grpc_pass with grpc:// for gRPC backend URLs [OK]
Common Mistakes:
Using proxy_pass instead of grpc_pass
Using http:// instead of grpc://
Omitting the semicolon at the end
3. Given this nginx snippet inside a server block:
What happens if the backend server at backend:9000 is down?
medium
A. nginx silently drops the request without response
B. nginx returns the custom error page at /error502grpc
C. nginx returns a default 404 Not Found error
D. nginx retries the request indefinitely
Solution
Step 1: Understand error_page directive usage
The error_page 502 = /error502grpc; tells nginx to serve the URI /error502grpc when a 502 Bad Gateway error occurs.
Step 2: Recognize backend down causes 502 error
If the backend is down, nginx cannot connect and returns a 502 error, triggering the custom error page.
Final Answer:
nginx returns the custom error page at /error502grpc -> Option B
Quick Check:
502 error triggers custom error_page [OK]
Hint: 502 errors can be customized with error_page directive [OK]
Common Mistakes:
Assuming 404 is returned for backend failure
Thinking nginx retries endlessly
Ignoring error_page directive effect
4. You configured nginx to proxy gRPC with:
grpc_pass grpc://backend:50051;
But clients report connection errors. Which nginx configuration is missing?
medium
A. fastcgi_pass backend;
B. listen 80;
C. proxy_http_version 1.1;
D. listen 443 ssl http2;
Solution
Step 1: Identify protocol requirements for gRPC
gRPC requires HTTP/2 support, so nginx must listen with http2 enabled.
Step 2: Check the listen directive
listen 443 ssl http2; includes listen 443 ssl http2; which enables HTTP/2 over TLS, necessary for secure gRPC connections. Options B and C do not enable HTTP/2, and A is unrelated.
Final Answer:
listen 443 ssl http2; -> Option D
Quick Check:
HTTP/2 is required for gRPC proxying [OK]
Hint: Enable HTTP/2 with listen directive for gRPC [OK]
Common Mistakes:
Not enabling http2 in listen directive
Using proxy_http_version 1.1 instead of http2
Confusing fastcgi_pass with grpc_pass
5. You want nginx to proxy gRPC securely to a backend using TLS on port 50051. Which configuration snippet correctly sets this up?
hard
A. grpc_pass grpcs://backend:50051; listen 443 ssl http2;
B. grpc_pass grpc://backend:50051;
C. proxy_pass grpcs://backend:50051; listen 443 ssl http2;
D. grpc_pass grpc://backend:50051; listen 80;
Solution
Step 1: Use grpcs:// for secure gRPC backend
To proxy gRPC over TLS, the backend URL must start with grpcs://.
Step 2: Enable SSL and HTTP/2 on nginx listen
Listening on port 443 with ssl and http2 is required for secure gRPC proxying.
Step 3: Verify correct directive usage
Use grpc_pass (not proxy_pass) with the secure URL and proper listen directive.
Final Answer:
grpc_pass grpcs://backend:50051; listen 443 ssl http2; -> Option A
Quick Check:
Secure gRPC needs grpcs:// and ssl http2 [OK]
Hint: Use grpcs:// and listen 443 ssl http2 for secure gRPC [OK]
Common Mistakes:
Using grpc:// instead of grpcs:// for TLS
Not enabling ssl and http2 on listen
Using proxy_pass instead of grpc_pass
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.