back to labs
Nginx Reverse Proxy: Front an App, Keep the Host Header
MediumNetworking20-30 minThe brief
A backend app listens on http://127.0.0.1:<port> (local only). Put nginx in front of it as a reverse proxy. Write a server block under /etc/nginx/ so that:
- requests to
/api/are proxied to the backend (proxy_pass) - the backend receives the original Host header (
proxy_set_header Host $host;) — it routes by Host - everything else (
/) is served as static files from the docroot - the server answers for the given
server_nameon port 80
The backend port, server name, and docroot for this session are in /root/brief.txt. Grading reads the config — it does not start nginx (on a live host you'd run nginx -t then systemctl reload nginx).
What you'll do
- Configure nginx as a reverse proxy with proxy_pass
- Preserve the client Host header to the backend (proxy_set_header)
- Combine a proxied location with a static-file location in one server block
Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.
