liveBook · Manning

Reverse proxy

As explained in Road to Kubernetes

A reverse proxy is a network intermediary that accepts client requests and forwards them to one or more backend servers or applications.

A reverse proxy accepts incoming web requests and forwards them to backend applications. NGINX can route requests by URL while keeping Python and Node.js services behind one public entry point. section 3.6 section 3.6.1

A practical deployment uses a reverse proxy to:

  • Expose applications through normal web URLs instead of their application ports. section 3.5.2
  • Hide backend applications such as Python and Node.js services from direct access. section 3.6
  • Forward traffic to local services or reachable applications on other addresses. section 3.6
  • Provide a foundation for load balancing, while leaving advanced balancing details aside. section 3.6

Route two applications with NGINX

Configure one server block to send / to http://localhost:8888, where gunicorn serves the Python application, and /js/ to http://localhost:3000/, where Express runs on Node.js. Enable the site through sites-enabled, remove the default configuration, and restart NGINX. section 3.6.1

Listing 3.34 NGINX reverse proxy configuration
cat <<EOF > /etc/nginx/sites-available/roadtok8s
server {
    listen 80;
    server_name localhost;

    location / {#1
        proxy_pass http://localhost:8888;
    }

    location /js/ {#2
        proxy_pass http://localhost:3000/;
    }
}
EOF

Inspect the compact NGINX configuration that maps URL locations to the two backend services. section 3.6.1

How Road to Kubernetes covers it

How deep it goes
Explains forwarding, URL locations, site enablement, default removal, and restart, while deferring advanced load-balancing details.
Examples
Uses NGINX locations mapping / to gunicorn on port 8888 and /js/ to Express on port 3000.
What it assumes
Assumes running Python and Node.js applications managed by Supervisor, then demonstrates routing them through NGINX.
What you can do after
Operate/configure NGINX to expose multiple backend applications through URL paths and restart the service after enabling configuration.
How it connects
Connects NGINX with load balancing, Supervisor, gunicorn, Express, Node.js, firewalls, and web application deployment.

Also explained in

Compare how 5 books explain reverse proxy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.