0
0
Flaskframework~10 mins

Nginx as reverse proxy in Flask - Interactive Code Practice

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

Complete the code to define a simple Flask app that returns 'Hello World'.

Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return [1]
Drag options to blanks, or click blank then click option'
Aprint('Hello World')
BHello World
C'Hello World'
Dreturn 'Hello World'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string
Using print instead of return
2fill in blank
medium

Complete the Nginx server block to listen on port 80.

Flask
server {
    listen [1];
    server_name example.com;

    location / {
        proxy_pass http://127.0.0.1:5000;
    }
}
Drag options to blanks, or click blank then click option'
A80
B443 ssl
C8080
D5000
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTTPS port 443 without SSL configuration
Using Flask app port 5000 instead of Nginx port
3fill in blank
hard

Fix the error in the proxy_pass directive to correctly forward requests to the Flask app.

Flask
location / {
    proxy_pass [1];
}
Drag options to blanks, or click blank then click option'
Ahttp://127.0.0.1:80
Blocalhost:5000
Chttp://localhost:5000/
Dhttp://localhost:5000
Attempts:
3 left
💡 Hint
Common Mistakes
Adding trailing slash in proxy_pass
Missing http:// in URL
Using wrong port
4fill in blank
hard

Fill both blanks to set headers for the reverse proxy to pass the original host and client IP.

Flask
location / {
    proxy_set_header [1] $host;
    proxy_set_header [2] $remote_addr;
}
Drag options to blanks, or click blank then click option'
AHost
BX-Real-IP
CX-Forwarded-For
DServer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Server' header incorrectly
Confusing 'X-Forwarded-For' with 'X-Real-IP'
5fill in blank
hard

Fill all three blanks to complete the Nginx config for proxy buffering and timeouts.

Flask
location / {
    proxy_buffering [1];
    proxy_connect_timeout [2]s;
    proxy_read_timeout [3]s;
}
Drag options to blanks, or click blank then click option'
Aon
B30
C60
Doff
Attempts:
3 left
💡 Hint
Common Mistakes
Setting proxy_buffering to 'on' when real-time is needed
Using wrong units for timeouts