Complete the code to define a simple Flask app that returns 'Hello World'.
from flask import Flask app = Flask(__name__) @app.route('/') def home(): return [1]
The Flask route function must return a string. Using quotes around 'Hello World' returns the string correctly.
Complete the Nginx server block to listen on port 80.
server {
listen [1];
server_name example.com;
location / {
proxy_pass http://127.0.0.1:5000;
}
}Port 80 is the default HTTP port that Nginx listens on for web traffic.
Fix the error in the proxy_pass directive to correctly forward requests to the Flask app.
location / {
proxy_pass [1];
}The proxy_pass URL should not have a trailing slash to correctly forward requests to the Flask app.
Fill both blanks to set headers for the reverse proxy to pass the original host and client IP.
location / {
proxy_set_header [1] $host;
proxy_set_header [2] $remote_addr;
}Setting 'Host' passes the original host header, and 'X-Real-IP' passes the client IP to the Flask app.
Fill all three blanks to complete the Nginx config for proxy buffering and timeouts.
location / {
proxy_buffering [1];
proxy_connect_timeout [2]s;
proxy_read_timeout [3]s;
}Disabling proxy_buffering with 'off' helps with real-time responses. The connect timeout is 30 seconds, and read timeout is 60 seconds.