Complete the code to define the server listening on port 80.
server {
listen [1];
server_name example.com;
}The listen directive sets the port where Nginx listens for incoming requests. Port 80 is the default for HTTP.
Complete the code to forward requests to the backend server at localhost port 3000.
location / {
proxy_pass http://[1];
}The proxy_pass directive forwards requests to the backend server. Here, the backend runs on localhost at port 3000.
Fix the error in the proxy_pass directive to correctly forward to backend.
location /api/ {
proxy_pass http://127.0.0.1[1]3000/;
}The port number must be separated from the IP by a colon :. Without it, the address is invalid.
Fill both blanks to set headers that preserve the original client IP and host.
location / {
proxy_set_header [1] $remote_addr;
proxy_set_header [2] $host;
}X-Real-IP forwards the client's IP address, and Host preserves the original host header.
Fill both blanks to create a reverse proxy that listens on port 80, forwards to backend at 5000, and sets the correct headers.
server {
listen [1];
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header [2] $remote_addr;
}
}This configuration listens on port 80, forwards requests to backend at port 5000, and sets X-Real-IP header to pass client IP.