0
0
Nginxdevops~20 mins

gRPC proxying in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
gRPC Proxying Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
gRPC Proxying Basic Configuration Output
What will be the output status code when NGINX proxies a gRPC request to a backend that is up and running with this configuration?
Nginx
server {
    listen 50051 http2;
    location / {
        grpc_pass grpc://backend:50052;
    }
}
AHTTP/2 200 OK
BHTTP/1.1 500 Internal Server Error
CHTTP/2 404 Not Found
DHTTP/1.1 502 Bad Gateway
Attempts:
2 left
💡 Hint
Check if the grpc_pass directive points to a valid backend and if HTTP/2 is enabled.
Troubleshoot
intermediate
2:00remaining
Identifying the Cause of gRPC 502 Bad Gateway
Given this NGINX snippet, what is the most likely cause of receiving a 502 Bad Gateway error when proxying gRPC requests?
Nginx
server {
    listen 443 ssl http2;
    ssl_certificate /etc/ssl/certs/server.crt;
    ssl_certificate_key /etc/ssl/private/server.key;

    location / {
        grpc_pass grpc://127.0.0.1:50051;
    }
}
ANGINX does not support grpc_pass on port 443
BMissing proxy_set_header directives for gRPC metadata
CSSL certificates are invalid causing handshake failure
DThe backend gRPC server is not running or unreachable on 127.0.0.1:50051
Attempts:
2 left
💡 Hint
502 Bad Gateway usually means NGINX cannot connect to the backend service.
Configuration
advanced
2:00remaining
Correct gRPC Timeout Configuration
Which NGINX configuration snippet correctly sets a 10-second timeout for gRPC proxying to avoid hanging requests?
A
location / {
    grpc_pass grpc://backend:50051;
    grpc_read_timeout 10s;
}
B
location / {
    grpc_pass grpc://backend:50051;
    proxy_read_timeout 10s;
}
C
location / {
    grpc_pass grpc://backend:50051;
    grpc_send_timeout 10s;
}
D
location / {
    grpc_pass grpc://backend:50051;
    proxy_send_timeout 10s;
}
Attempts:
2 left
💡 Hint
Use the directive specific to gRPC read timeout, not generic proxy timeouts.
🔀 Workflow
advanced
3:00remaining
Order of Steps to Enable gRPC Proxying in NGINX
Arrange the steps in the correct order to enable gRPC proxying in NGINX for a new service.
A1,3,2,4
B2,1,3,4
C1,2,3,4
D2,3,1,4
Attempts:
2 left
💡 Hint
Think about starting backend first, then configuring proxy, then applying config, then testing.
Best Practice
expert
3:00remaining
Best Practice for Handling gRPC Errors in NGINX Proxy
Which configuration snippet correctly handles gRPC backend errors by returning a custom error message to clients?
A
error_page 502 = /grpc_fallback;
location = /grpc_fallback {
    internal;
    default_type application/grpc;
    add_header grpc-status 14;
    add_header grpc-message "Unavailable backend";
    return 204;
}
B
error_page 502 = /grpc_fallback;
location = /grpc_fallback {
    internal;
    default_type application/grpc;
    add_header grpc-status 14;
    add_header grpc-message "Unavailable backend";
    return 200;
}
C
error_page 502 = /grpc_fallback;
location = /grpc_fallback {
    internal;
    default_type application/grpc;
    add_header grpc-status 14;
    add_header grpc-message "Unavailable backend";
    return 503;
}
D
error_page 502 = /grpc_fallback;
location = /grpc_fallback {
    internal;
    default_type application/grpc;
    add_header grpc-status 14;
    add_header grpc-message "Unavailable backend";
    return 500;
}
Attempts:
2 left
💡 Hint
gRPC error responses use HTTP/2 200 with grpc-status trailer (14 = UNAVAILABLE) for proper client handling.