Proxies in a Nutshell
What is a proxy server?
A proxy server is an intermediate piece of software or hardware that sits between the client and the server. Clients connect to a proxy to make a request for a service like a web page, file, or connection from the server. Essentially, a proxy server (aka the forward proxy) is a piece of software or hardware that facilitates the request for resources from other servers on behalf of clients, thus anonymizing the client from the server.
Typically when we say proxy we mean forward proxy in general. Because forward proxies are often referred to as just proxies.
Forward Proxy!
A server that sits between a client and servers and acts on behalf of the client, typically used to mask the client’s identity(IP address).
Forward proxy acts as a client and takes client’s(Web Browser, Mobile App) requests and sends it to the server. Think of VPN which acts like a forward proxy and hides the client’s identity(IP address) by replacing client’s IP with its own. Server will think the forward proxy as the client and will send a response back to it. When forward proxy gets a response from the server it sends the response back to the client. You can think client and forward proxy a same team player working for each other.
Reverse Proxy!
A server that sits between a client and servers and acts on behalf of the servers, typically used for logging, load balancing, or caching.
Reverse proxy is opposite of forward proxy. Client sends a request to a reverse proxy thinking of it as the server. But how? here the DNS(Domain Name System) query resolves the ip address of the reverse proxy and sends it back to the user. Think what happens when your browser hits the URL of Amazon.com. Behind the seen what happens is the DNS resolver lookup for the ip address or location of amazon and if amazon’s server is configured with a reverse proxy the DNS resolver will send the ip address of the reverse proxy to the client but not the ip address of actual server. Client will think they are interacting with amazon’s server but the server and reverse proxy works as a the same entity as if there’s one server.
Reverse proxies filters the user requests and sends the valid requests to the actual server and also takes care of logging system. If the server wants to log stuff and gather matrics they can use reverse proxies. The best case of reverse proxy is to use them as a load balancer. A load balancer evenly distributes incoming traffic among the servers by using Round-Robin algorithm or complex algorithms like health checking of the server. When a malicious hacker sends tons of requests to bring down the server, the reverse proxy(load balancer) will work as a shield and will distribute the load among the servers to keep the system alive.
Nginx is a very popular webserver that’s often used as a reverse proxy and load balancer.
Thank you for reading :)