If you have been scrolling the web, you would have heard about the terms proxy and reverse proxy at least once. You might know a bit of them or might be completely unaware of what they are. This is completely okay with me, and if you have the desire to understand them, let’s continue.
In this post, we would get through proxy servers (forward & reverse) with its advantages. For few mins forget everything you know, and let’s start from scratch!
What is a Forward Proxy?
A proxy (aka forward proxy) server acts as a connection point between users and the internet. It’s a server that acts as an intermediary between end-users and the web pages.
Whenever you connect to the internet, it uses an IP address. This IP address is similar to your home’s address where packages are received and acts as a return address while sending parcels.
In a network instead of a physical parcel, we have packets of data circulating.
Simply a proxy server is a computer connected to the internet with its own IP address and channels your data to other servers while masking your IP.
How does a Proxy work?
When you make a web request, it first goes via the proxy server. After that, the proxy server makes your site request on your behalf, collects the response from the web server, and forwards the web page data to you so you can view it in your browser.
When the proxy server forwards your web requests, it may alter (encrypt) the data you send while still delivering the results you anticipate. Your IP address can be changed by a proxy server, because of which the web server doesn’t know where you are in the world.
Advantages of Proxy Server
Remember the time during your childhood when your parents were there to guard you against any outside influence. For example, if you need something like a toy. You didn’t go to the shop, but you asked your parents to get you one.
They went to the store and bought that for you. You didn’t have to deal with any external people, and they used to make sure you remain safe.
Well, we can think of proxy similarly. The proxy server provides your intranet with a layer of security or a firewall. Now people can’t infiltrate your computer or network via snooping onto your actual IP address.
Behind the closed intranet, you might have many machines looking to connect to the insecure internet. A proxy helps you accumulate all of the requests from various clients and then pass them on to the internet.
When you access a web page over the internet, the proxy server caches the web page for any subsequent visits. It saves bandwidth for the remaining machines inside the intranet and increases performance when the other clients request the same page.
Learn More about caching here!
The request from the client machine to the other servers is encrypted when gone through a proxy server. Only the information necessary to pass the request to another server is present, and this provides you with extreme security measures as your IP is masked.
If you wonder how Tor, the most secure network on the internet, works, then proxy server sets is the answer.
What is a Reverse Proxy?
In the forward proxy, the internet servers weren’t aware of the masked client, but things take a turn in reverse proxy. The reverse proxy is responsible for masking the servers from the outside internet, and this makes your servers get the same security and caching as the clients on a forward proxy get.
Moreover, you have few more advantages that make reverse proxy a must to have a toolkit in modern architecture.
Advantages of Reverse Proxy
A server’s job is to fulfil the client’s request. But sometimes, some of the requests comes out to be malicious. Proxy servers can block specific IPs to access the web servers and keep the system sound.
Load balancing is critical to any modern infrastructure as it keeps the servers healthy. Load balancing is a way to divert traffic to other parallel servers to load on one server, not too much. Another used case of a load balancer is to help developers keep the system functional while updating to a new version.
For example, you can be upgrading your system to
v1.1, but you need your application functioning. So you can divert your incoming traffic to
v1.0, the older version while your system is upgraded. We call this a rolling deployment.
Moreover, following along with this principle of load balancing, you can also perform A/B testing (canary deploy), i.e. serve two or more versions of service to different users. Canary deploys help you gather data and test which is the best implementation among two or more options.
Content Distribution Networks
One of the other widespread use cases of a reverse proxy is a CDN. Content Distribution Networks are essential for the modern infrastructure as they help people to access content with very low latency and load time.
Proxy servers (forward and reverse) are quite an essential component in modern system designs. Every system architect needs them for a more robust and efficient system, and having a grasp of these concepts is essential. Nginx and HAProxy are two popular examples and here are few links that would help you to get started!
I hope this post helped you understand the use cases and the functionalities of these critical infrastructures running the internet.