>_ IzzyLab

Hands-on task

This task is step 8 of the course “nginx basics”

Proxy an app through nginx

medium~10 min

An app is running on 127.0.0.1:3000, but only nginx should be exposed to the outside. Configure nginx on port 80 as a reverse proxy: it passes all requests on / to the app and returns its response.

What you'll practise:
  • nginx
  • reverse proxy
  • proxy_pass
  • location
  • web server

Topic breakdown

A reverse proxy is a front that generates nothing itself, but takes requests from the outside and forwards them to an internal app, returning its response to the client. The point: the app listens only on loopback and isn't exposed to the network, while nginx takes over port 80, TLS, caching, and rate limits. In the config, routing is described by server and location blocks, and the actual forwarding to the internal host:port is done by the proxying directive; after editing, the config is checked for syntax and the service is reloaded.

What's checked

  1. port 80 returns the app's response
  2. the response on :80 comes from the app on :3000
  3. nginx is running

What it looks like