Complete the code to specify the port Nginx listens on.
server {
listen [1];
location / {
proxy_pass http://127.0.0.1:8000;
}
}The listen directive tells Nginx which port to listen on. Port 80 is the default for HTTP.
Complete the code to set the proxy header for the original host.
location / {
proxy_set_header Host [1];
proxy_pass http://127.0.0.1:8000;
}The proxy_set_header Host $host; passes the original host header to the backend server.
Fix the error in the proxy_pass URL to correctly forward requests to Django.
location / {
proxy_pass http://127.0.0.1[1]8000;
}The proxy_pass URL must have a colon before the port number, like http://127.0.0.1:8000.
Fill both blanks to set headers for real IP and forwarded protocol.
location / {
proxy_set_header X-Real-IP [1];
proxy_set_header X-Forwarded-Proto [2];
proxy_pass http://127.0.0.1:8000;
}X-Real-IP should be set to $remote_addr to pass the client's IP. X-Forwarded-Proto uses $scheme to indicate HTTP or HTTPS.
Fill all three blanks to correctly configure proxy headers for Django behind Nginx.
location / {
proxy_set_header Host [1];
proxy_set_header X-Real-IP [2];
proxy_set_header X-Forwarded-For [3];
proxy_pass http://127.0.0.1:8000;
}These headers ensure Django receives the original host, client IP, and the chain of forwarded IPs.