# Reverse Proxying Architecture & Deployment --- ## What is a proxy?
A [**proxy server**](https://en.wikipedia.org/wiki/Proxy_server) is a computer or application that acts as an **intermediary** for requests from clients seeking resources from other servers. --- ## Types of proxy servers There are 3 main kinds: - [**Tunneling proxy**](https://en.wikipedia.org/wiki/Tunneling_protocol) or [**gateway**](https://en.wikipedia.org/wiki/Gateway_(telecommunications)) - [**Forward proxy**](https://en.wikipedia.org/wiki/Open_proxy) - [**Reverse proxy**](https://en.wikipedia.org/wiki/Reverse_proxy) --- ## Tunneling proxy
A [tunneling proxy](https://en.wikipedia.org/wiki/Tunneling_protocol) can pass **unmodified requests and responses** from one network to another. **Notes:** It can also be used to encapsulate a protocol into another, such as running IPv6 over IPv4. For example, an SSH connection may be relayed by a proxy server to a different target server. The proxy server simply passes the packets through, with no ability to compromise the security of the communication. [**Virtual private networks (VPN)**](https://en.wikipedia.org/wiki/Virtual_private_network) use tunneling protocols, usually with an additional layer of encryption. --- ## Forward proxy
A **forward proxy** retrieves data from a server on behalf of a client. It is said to be [**open**](https://en.wikipedia.org/wiki/Open_proxy) if it is accessible by any Internet user. **Notes:** A forward proxy works for its clients. It sits on their side, often in their own network, and they go through it to reach any server on the Internet. --- ### Anonymous forward proxy
Internet
Client
Anonymous proxy
Website
sees only the proxy
Conceals the identity of the client. **Notes:** An **anonymous forward proxy** reveals its identity as a server but conceals that of the client. Since the target server does not know who the original client is, it can be used to protect privacy. [VPNs](https://en.wikipedia.org/wiki/Virtual_private_network) are often used in combination with this type of proxy server. --- ### Transparent forward proxy
Intercepts the client's requests without the client having to configure anything, and does not hide the client. **Notes:** A **transparent forward proxy** is transparent to its clients: they do not configure it, and may not even know it is there. The network they are connected to sends their requests through it. Schools and companies often use this kind of proxy to cache websites, or to restrict access to particular websites (e.g. Facebook). It does not hide the clients: it usually tells the server who the original client is, through HTTP headers. The word is not used consistently. Some only mean a proxy that reveals the original client, whether the client configured it or not. When many clients go through the same forward proxy server, its IP address may get banned, since the target server only sees one computer (the proxy) making too many requests at the same time. --- ## Reverse proxy
A [**reverse proxy**](https://en.wikipedia.org/wiki/Reverse_proxy) is an **internal-facing proxy** used to control and protect access to servers in a **private network**. **Notes:** A reverse proxy **appears to clients to be an ordinary server**, but actually **transmits their requests to** one or more **other servers in an internal private network** which handle the requests. It is the mirror image of a forward proxy: it works for the servers, and sits on their side. --- ## Why use a reverse proxy?
--- ### Sharing a port
Only **one process** can listen on a port: the reverse proxy listens on port 80 **for every site**, and forwards each request **by the name of the site**. **Notes:** A port is a number the kernel uses to hand incoming data to the one process listening on it. If two processes could listen on the same port, the kernel would not know which of them to hand the data to. So it refuses to let a second process listen on a port that is already taken. When an address has no port, browsers connect to port 80 for HTTP, and 443 for HTTPS. If an application listens on port 80 itself, no other application on the same server can be reached without a port in its address. A reverse proxy is one more process between the browser and the application, with a connection on each side. It is the only process listening on port 80. Each application listens on a port of its own, which nobody needs to type. The DNS gives all the names of the sites on the server the same IP address, so the name is the only thing that tells the sites apart. The browser sends it in the `Host` header of every HTTP request, and the reverse proxy forwards the request to the application configured for that name. This is called [**name-based virtual hosting**](https://en.wikipedia.org/wiki/Virtual_hosting#Name-based). --- ### Hiding internal architecture
Client
Internet
Client
Reverse proxy
example.com
Private network
Another network
Website A
Website B
Website C
Reverse proxies can **hide the existence and characteristics of an internal network's private servers**. **Notes:** The client only sees the proxy server. The response from the private server is returned as if it was coming from the proxy server itself, leaving the client with no knowledge of the structure of the internal network. It is unaware of the complexity of the internal architecture, and does not have to worry about it: the proxy can hide anything from a single application to many servers, in several networks. In a scenario where you have only a single public IP address available, a reverse proxy allows you to make multiple private servers accessible on that IP address through the proxy server. The other way round, the servers behind the proxy only see the proxy. For them, it is a client like any other: every connection they receive comes from the proxy, not from the original client. If a server needs to know who the original client is, for example to record their IP address, the proxy has to tell it, by adding HTTP headers to the requests it forwards. The [appendix of the subject](/2026/course/509-reverse-proxy/#appendix-what-the-application-sees) shows how. --- ### Hiding multi-component websites
Client
Servers' network
Internet
Browser
Frontend
Backend
www.example.com
api.example.com
Reverse proxy
example.com
**Notes:** Modern websites can be complex applications, often with a **separate frontend and backend** developed by different teams with different technologies. Putting a reverse proxy in front can make it **appear as one single website** on a single domain name, avoiding [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) issues. --- ### SSL/TLS termination
A reverse proxy can be the **secure endpoint** with all the SSL/TLS certificates, then **forwarding unencrypted requests** to other servers in the private network. **Notes:** Managing SSL/TLS certificates to provide websites over HTTPS is rather complex. It can be hard to configure some frameworks or tools to ensure they are only using secure communications. --- ### Scalability
[Scalability](https://en.wikipedia.org/wiki/Scalability) is the capability of a computer system to handle a growing amount of work (e.g. client requests). **Notes:** There are [2 broad ways](https://en.wikipedia.org/wiki/Scalability#Horizontal_and_vertical_scaling) of adding more resources for a particular application. **Vertical scaling** consists in using a more powerful computer, with more CPU, RAM, throughput, etc. The added power will allow the server to serve more clients. **Horizontal scaling** means adding more computers to handle the same work. For example, 3 instances of a web application can probably handle 3 times as many clients at the same time. Computers or applications can be combined in [clusters](https://en.wikipedia.org/wiki/Computer_cluster) to improve performance. --- #### Load balancing
A common function of reverse proxies is to perform [**load balancing**](https://en.wikipedia.org/wiki/Load_balancing_(computing)), i.e. the distribution of workloads across multiple applications or servers to achieve **horizontal scaling**. **Notes:** As multiple clients arrive simultaneously, the reverse proxy will distribute requests to different servers, spreading the load between them. --- ### Other uses - [Web acceleration](https://en.wikipedia.org/wiki/Web_accelerator) - On-the-fly compression - Spoon-feeding - [Denial-of-service (DoS)](https://en.wikipedia.org/wiki/Denial-of-service_attack) protection - [A/B testing](https://en.wikipedia.org/wiki/A/B_testing) - Authentication **Notes:** - [Web acceleration](https://en.wikipedia.org/wiki/Web_accelerator) is the caching of static content and dynamic content to reduce load on internal servers. - Optimize content by transparently compressing it to speed up loading times. - _Spoon-feeding_ is a technique where the reverse proxy temporarily stores a dynamically generated page, then serves it to the client a little bit at a time. This avoids the internal server having to wait for slow clients such as mobile applications. - A reverse proxy can require **authentication** before letting a client access an insecure application, adding security without having to modify the application itself. - And [more](https://en.wikipedia.org/wiki/Reverse_proxy#Uses_of_reverse_proxies) --- ## nginx
--- ### What is nginx?
[nginx](https://nginx.org/) is a competitor of the well-known [Apache HTTP server](https://httpd.apache.org/), first released in 2004 to solve the [C10k problem](https://en.wikipedia.org/wiki/C10k_problem). **Notes:** [nginx](https://nginx.org/) is an HTTP and reverse proxy server, and one of the most used web servers in the world. It was developed to solve the [C10k problem](https://en.wikipedia.org/wiki/C10k_problem), i.e. the capability of a computer system to handle ten thousand concurrent connections, thanks to its [event-driven architecture](https://blog.nginx.org/blog/inside-nginx-how-we-designed-for-performance-scale). It also has [many other features](https://nginx.org/en/#basic_http_features) to serve modern web applications. --- ### How nginx runs
A **master** process, started as `root`, opens the ports. **Worker** processes, running as an unprivileged user, handle the requests. **Notes:** On Linux, only `root` may listen on a port below 1024, such as 80 or 443. An application that listened on port 80 itself would have to run as `root`, and so would anyone who found a vulnerability in it. nginx starts as `root` only to open its ports. Its master process then starts worker processes, usually one per processor core, which run as an unprivileged user, `www-data` on Ubuntu, and handle all the requests. Each worker can handle many connections at once. The applications behind nginx listen on ports above 1024, which any user may do, so each can run as a dedicated user of its own. The master process also reacts to signals. When it receives the `HUP` signal, it reads its configuration again, starts new workers with it, and lets the old ones finish the requests they are handling. The configuration changes without nginx ever stopping listening. If the new configuration has an error, nginx keeps the old one. --- #### Apache vs. nginx
**Notes:** nginx is used by more websites than Apache, and by more high-traffic websites. In November 2026, [W3Techs](https://w3techs.com/technologies/overview/web_server) found nginx on 30.0% of the websites whose web server it knows, and Apache on 20.9%. Cloudflare Server, used by even more websites (33.8%), is not a server you install: it is Cloudflare's own network of reverse proxies, which many websites put in front of their own servers. [ab-testing]: https://en.wikipedia.org/wiki/A/B_testing [apache]: https://httpd.apache.org/ [c10k]: https://en.wikipedia.org/wiki/C10k_problem [cluster]: https://en.wikipedia.org/wiki/Computer_cluster [cors]: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing [dos]: https://en.wikipedia.org/wiki/Denial-of-service_attack [gateway]: https://en.wikipedia.org/wiki/Gateway_(telecommunications) [horizontal-and-vertical-scaling]: https://en.wikipedia.org/wiki/Scalability#Horizontal_and_vertical_scaling [load-balancing]: https://en.wikipedia.org/wiki/Load_balancing_(computing) [name-based-virtual-hosting]: https://en.wikipedia.org/wiki/Virtual_hosting#Name-based [nginx]: https://nginx.org/ [nginx-features]: https://nginx.org/en/#basic_http_features [nginx-performance]: https://blog.nginx.org/blog/inside-nginx-how-we-designed-for-performance-scale [open-proxy]: https://en.wikipedia.org/wiki/Open_proxy [proxy]: https://en.wikipedia.org/wiki/Proxy_server [reverse-proxy]: https://en.wikipedia.org/wiki/Reverse_proxy [reverse-proxy-uses]: https://en.wikipedia.org/wiki/Reverse_proxy#Uses_of_reverse_proxies [scalability]: https://en.wikipedia.org/wiki/Scalability [tunneling-proxy]: https://en.wikipedia.org/wiki/Tunneling_protocol [vpn]: https://en.wikipedia.org/wiki/Virtual_private_network [w3techs-web-servers]: https://w3techs.com/technologies/overview/web_server [web-acceleration]: https://en.wikipedia.org/wiki/Web_accelerator [what-the-application-sees]: /2026/course/509-reverse-proxy/#appendix-what-the-application-sees
GitHub