Bookmarks

Reverse proxy

A proxy server that accepts client requests on behalf of a group of servers: the client talks to it as if it were the service itself, and it passes each request inside and returns the response.

Also: reverse proxy server, reverse-proxy, rev proxy

checked 9 Nov

All terms

A reverse proxy sits at the entrance to a website or API. To the client it looks like the service itself, but it generates nothing: it forwards requests to internal servers and returns their responses. A typical example is nginx in front of an application backend, which accepts HTTPS, serves static files and sends other requests to the application.

How it differs from a forward proxy

A forward proxy works on the client side: a user or network admin configures it, and servers see only the proxy, not the individual computers behind it. A reverse proxy works on the service owner’s side: clients don’t know which internal server will handle their request.

QuestionForward proxyReverse proxy
Whose sidethe client or corporate networkthe server owner
Who it hidesclients from serversservers from clients
Who configures ita user or network adminthe site or service admin
Examplea corporate gateway to the internetnginx at the entrance to a web application

What it does

  • Terminates TLS: holds the certificate and the HTTPS connection with the client, and passes requests inside over plain HTTP or a secure channel.
  • Distributes requests among several identical servers using load-balancing algorithms.
  • Caches responses and serves repeated requests without contacting the backend.
  • Serves static files directly, sparing the application.
  • Limits request rates and, together with a WAF, filters out obviously malicious traffic.
  • Compresses responses and adds caching headers.

Example: nginx

A minimal configuration: nginx accepts requests to the site and passes them to the application on a local port.

nginx
            server {                listen 443 ssl;                server_name example.uz;                ssl_certificate     /etc/ssl/example.uz.crt;                ssl_certificate_key /etc/ssl/example.uz.key;                 location / {                    proxy_pass http://127.0.0.1:8000;                    proxy_set_header Host $host;                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                }            }            

nginx holds the HTTPS connection with the client, while the application receives the request over HTTP on port 8000. The X-Forwarded-For header tells the application the client’s real address; otherwise it would see only the proxy’s address.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • API gateway

    A reverse proxy passes HTTP traffic through as it is; an API gateway builds on it for APIs: access control, rate limits, response aggregation.

  • load balancer

    A load balancer only distributes requests among servers; a reverse proxy does that plus TLS, caching and static files, often in a single program.

  • CDNcontent delivery network

    A CDN is a distributed network of nodes, each acting as a reverse proxy close to the user; your own proxy is a single one at the entrance to your site.

In depth in the references

where the topic is covered in detail