Tuesday, September 25, 2018

Forward and Reverse Proxy

Overview

Before talking about forward proxy and reverse proxy let's talk about what is the meaning of proxy.
Basically proxy means someone or something is acting on behalf of someone.
In the technical realm, we are talking about one server is acting behalf of the other servers.

In this blog, we will talk about web proxies. So basically we have two types of web proxies:-

  • Forward Proxy
  • Reverse Proxy
The forward proxy is used by the client, for example:- web browser, whereas reverse proxy is used by the server such as web server.

Forward Proxy

In Forward Proxy, proxy retrieves data from another website on the behalf of original requestee. For example:- If an IP is blocked for visiting a particular website then the person(client) can use the forward proxy to hide the real IP of the client and can visit the website easily.

Let's take another example to understand it more clearly. For example, we have 3 server

Client                      -> Your computer from which you are sending the request
Proxy Site               -> The proxy server, proxy.example.com
Main Web server    -> The website you want to see

Normally connection can happen like this 

In the forward proxy, the connection will happen like this



So here the proxy client is talking to the main web server on the behalf of the client.

The forward proxy also acts as a cache server. For example:- If the content is downloading multiple times the proxy can cache the content on the server so next time when another server is downloading the same content, the proxy will send the content that is previously stored on the server to another server. 

 Reverse Proxy

The reverse proxy is used by the server to maintain load and to achieve high availability. A website may have multiple servers behind the reverse proxy. The reverse proxy takes requests from the client and forwards these requests to the web servers. Some tools for reverse proxy are Nginx, HaProxy.

So let's take the similar example as the forward proxy


Client                      -> Your computer from which you are sending the request
Proxy Site               -> The proxy server, proxy.example.com

Main Web server    -> The website you want to see


Here it is better to restrict the direct access to the Main Web Server and force the requests or requestors to go through Proxy Server first. So data is being retrieved by Proxy Server on the behalf of Client.

  • So the difference between Forward Proxy and Reverse Proxy is that in Reverse Proxy the user doesn't know he is accessing Main Web Server, because of the user only communicate with Proxy Server.
  • The Main Web Server is invisible for the user and only Reverse Proxy Server is visible. The user thinks that he is communicating with Main Web Server but actually Reverse Proxy Server is forwarding the requests to the Main Web Server.

4 comments:

  1. It would be great if you give tools or name of forward proxy that a requestee could use??

    Like haproxy and nginx in case of reverse proxy.

    ReplyDelete
  2. It is very helpful. Good article

    ReplyDelete