A tale of proxy server
25 Jan, 2024 |
4 mins read
In a land far far away, there was a King. The king had a beautiful daughter…
Wait a minute, there must be a king and a princess to make it a fairy tale, right? And you guessed it right. There should be a country boy too. It’s a love story. Better than ‘twilight’, of course.
So, the country boy had fallen in love with the princess. The princess is soft for him too. But there is no way for the boy to contact with the princess because of the guards at the palace. But here comes the BFF of the princess to rescue. The BFF of the princess is happened to be acquainted with the boy too. So whenever the boy needs to send any message to the princess, he sent it to the BFF and she passed it to the princess. Same way the response from the princess comes back to the boy via the BFF.
I don’t know what happened next but I can only wish that something good happened and that they lived happily ever after.
So, let’s make it clear how the story is related to the topics I am going to write about.
Did you ever face a situation where you can’t access a site from your educational institute/home/office because it is blocked or you don’t have access to the network outside you are working? Or you wanted to see a YouTube video but can’t because it is unavailable in your country?? What did you do next? If you are clever you might have used some application called ‘proxy’ which bypasses all these restrictions and gets you the content you want. Yup! that’s right, you are the ‘boy’, this proxy is the ‘BFF’ of our princess and the site is the ‘princess’ whom we wanted to contact.
Simply speaking, a ‘proxy server’ is a go-between or intermediary between you and your origin server. Generally, when you browse a site or a service, your PC/device sends a request to the origin server which hosts the site/service and sends you back the content you wanted. But in terms of a proxy, you send the request to the ‘proxy server’, it gets your request which lets it know which server you want to contact, then it contacts the origin Server, gets the content, and sends it back to you. Simple as that.
In general, there are two types of proxy servers, which are known as:
Forward proxy server
Reverse proxy server
In the ‘forward proxy server’, the origin server doesn’t know who the actual ‘requestee’ is. The server assumes that the ‘proxy server’ is the actual requestee, so it sends back the response to it, and then the proxy server returns the same response to the actual requestee(that means you).
Forward Proxy Server request-response flow
On the other hand, ‘reverse proxy’ is kind of the inverse of the ‘forward proxy’. In that case, think that the main server is secured behind a protected network, and you can’t directly contact it. You wouldn’t know where it is actually. You can only access to a proxy server, in this case, it is known as a ‘reverse proxy server’, and the proxy server will connect with the actual server to get you the content. You/client would assume that the proxy server is the ‘origin server’.
Reverse Proxy Server
Do you need a single-line simple explanation?
Here it goes:
Now, what would be some of the uses for forward and reverse proxies? (collected from here)
Forward proxy server
Accessing blocked sites over SSL
Serving geo-restricted content by identifying servers within the approved location
Caching proxied content to improve speeds to frequently used sites
Reverse proxy server
Balancing loads between multiple disparate servers
Redirecting traffic to a secondary server when undergoing maintenance or testing on your main one
Providing a layer of protection for a real server by allowing access only through designated Nginx servers
That’s it. Hopefully, you got an overview of the concept.
The following links have some nice explanations and descriptions about proxy servers.
Apache Doc
StackOverflow