A tale of proxy server
Photo by Cederic Vandenberghe on Unsplash

A tale of proxy server

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:

  1. Forward proxy server
  2. 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:

  • Forward Proxy: Acting on behalf of a requester (or service consumer)
  • Reverse Proxy: Acting on behalf of service/content producer.

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


Previously published on my blog: https://ahmedshamim.com/posts/a-tale-of-proxy-server

Shrabon Talukder

Frontend Web Developer | Expert in HTML, CSS, JavaScript, jQuery, React.js, Vue.js, PHP | Skilled in Tailwind CSS, Bootstrap | Git & GitHub Enthusiast | WordPress Specialist with Elementor & WooCommerce Mastery.

1 年

Great article, Ahmed Shamim Hassan! Your clear explanation really helps in understanding the difference between 'forward proxy' and 'reverse proxy' servers. Keep up the informative content!

Thanks for the insight on proxy in such a way. ??

要查看或添加评论,请登录

Ahmed Shamim Hassan的更多文章

  • Observer vs Pub-Sub Pattern

    Observer vs Pub-Sub Pattern

    I was once asked in an interview: “What is the difference between the observer pattern and the pub-sub pattern?” I…

    3 条评论
  • Webhook for You and Me

    Webhook for You and Me

    You won’t (maybe) ever ask again: “What’s a webhook, mom?” I’m the kind of person who practices a habit of explaining…

    4 条评论
  • Probabilistic Data Structures: Bloom filter

    Probabilistic Data Structures: Bloom filter

    If you have a glass-protected bookshelf, it will protect your books from dust and insects. However, it will cost you…

    4 条评论
  • How Do You Authenticate, Mate?

    How Do You Authenticate, Mate?

    A definitive guide to authentication for software developers! We all know the common procedure for authenticating a…

    6 条评论
  • What Every Programmer Should Know About ‘String’

    What Every Programmer Should Know About ‘String’

    A ‘String’ is a sequence of characters. Considering you’re most likely a programmer, there is a high probability that…

    2 条评论

社区洞察

其他会员也浏览了