Complete the code to create a basic Express server that listens on port 3000.
const express = require('express'); const app = express(); app.get('/', (req, res) => { res.send('Hello from Express!'); }); app.listen([1], () => { console.log('Server running'); });
The Express server listens on port 3000, which is a common default for development.
Complete the Nginx configuration line to set the proxy pass URL to the Express server running on localhost port 3000.
location / {
proxy_pass http://[1];
}The proxy_pass should point to the Express server URL, which is localhost on port 3000.
Fix the error in the Nginx proxy configuration to correctly forward headers.
location /api/ {
proxy_pass http://localhost:3000/;
proxy_set_header Host [1];
}The proxy_set_header Host should be set to $host to preserve the original host header.
Fill both blanks to complete the Nginx configuration that forwards requests and sets headers for proxying.
location /app/ {
proxy_pass http://localhost:[1]/;
proxy_set_header X-Real-IP [2];
}The proxy_pass port should be 3000 to match Express, and X-Real-IP header should be set to $remote_addr to pass client IP.
Fill in the blanks to complete the Express middleware that trusts the proxy and logs the real client IP.
const express = require('express'); const app = express(); app.set('[1]', true); app.use((req, res, next) => { console.log('Client IP:', req.[2]); next(); });
Setting 'trust proxy' to true tells Express to trust the proxy headers. The client IP is accessed via req.ip.