DEV Community

Cover image for Proxy vs Reverse Proxy
Tamerlan Gudabayev
Tamerlan Gudabayev

Posted on • Edited on

Proxy vs Reverse Proxy

I know sometimes it's very overwhelming.

You look at a developer's roadmap post, video, whatever. There are like 100 stuff over there to learn.

It's very disheartening in the beginning, but I eventually realized that there are some core concepts that are used in many different places.

Going in from that, while studying design patterns, and servers, the word proxy showed up quite a bit. So I did the hard work for you and researched what the hell are proxies and how do they work. I want to share with you what I have learned about proxies (it's not complicated what so ever).

Table of contents

What are proxies?

Let's forget about code, and look at the English language for a second.

If you google proxy meaning on google, you might get something like this.

the authority to represent someone else, especially in voting.

This is very handy in real life, let's say you are your country's president and you have been invited to some semi-important conference, but as a president you're to busy to go there. Your advisors would tell you to simply send someone in your stead, which can be let's say the vice-president or something. He would go in your stead and handle the conference and you would handle your own work. It's a win-win situation. By the end of this, you can say that the vice-president is acting as a proxy to the president.

Going back to technical terms, a proxy is simply a way to hide the client from the server.

Alt Text

Let's go through the process of going to google.com

  1. You open your browser, type in google.com, and finally click enter.
  2. Your ISP receives a request that you want to go to google.com
  3. Your ISP does the request for you and returns back google.com files.

In a way your ISP (Internet Service Provider) is a proxy. They do the request for you, and the server (google.com) does not know the client (you). It only knows your ISP which is acting as you but not being you. I know this sounds weird.

Where are they used?

They are used everywhere but let's highlight a couple of key use cases.

  • Caching: When there are many requests to a specific site, the proxy can simply cache the site and return from the cache, it does not have to make a request to the server which is definitely slower than cache.
  • Anonymity: As the server does not know who the real client is, you get anonymity.
  • Logging: You can get logs to incoming traffic, to know which sites are being visited. This is how your ISP know which sites are being visited the most.
  • Block Sites: ISP usually do this trick, where they beforehand see which site you wanna go to and then say "oh shit this is bannedsite.com", instead of routing your request, I'm gonna give you a HTTP 404 page.
  • Microservices: The deal with microservices is that to keep them decoupled (which is a good thing) they don't have to know about each other. Using proxies while communicating with services adds anonymity, which in turn reduces coupling.

What's a reverse proxy?

I bet you by now, you know what's the meaning of reverse and proxy.

Simply speaking a reverse proxy, is a revered proxy.

Let me explain

Alt Text

Reverse proxy diagram

A reverse proxy hides the server from the client.

It's simple as that, in the diagram above we are going to example.com, but the client doesn't know which server is it going to, it can be server A, B, or C. You might ask why we would want to do this, well sometimes a single server is simply not enough to handle all the load. Let's say google.com can't only have one server, they go servers per country to support localization. There are many reasons why you would want to implement a reverse proxy.

Where is a reverse proxy used?

  • Caching: Same thing with the normal proxy, you can cache data, instead of calling the backend.
  • Load Balancing: Imagine you got like a million requests to a site at once, if you put them all in one server, your server will almost definitely crash. But with load balancing, you can have multiple servers to balance the load (number of requests).
  • Ingres: What it basically is you can have different servers for different requests, meaning let's say you go to route example.com/pictures you will be routed to the picture Server. Route /videos will be routed to the Video server.
  • Canary Deployment: are a pattern for rolling out releases to a subset of users or servers. The idea is to first deploy the change to a small subset of servers, test it, and then roll the change out to the rest of the servers.

FAQ

Can I use a proxy instead of a VPN for annonimity?

For basic internet usage you can simply use a proxy, but a VPN is superior because they encrypt and secure all of your network traffic, not just the HTTP or SOCKS calls from your browser like a proxy server.

Is proxy just for HTTP traffic?

No, there are many types of proxies. This includes:

  1. Web Proxy (HTTP)
  2. Secure Web Proxy (HTTPS)
  3. FTP Proxy
  4. SOCKS Proxy
  5. Streaming Proxy (RTSP)
  6. Gopher Proxy

Additional References

Top comments (1)

Collapse
 
harshdeep61034 profile image
Harsh Deep

Nice Blog, i think you studied from hussein nasseir.