You need a Proxy Server to proctect you 🛡️🐞
Tags: systemdesign, performance, architecture, security
Published: 2024-02-21 21:35:31

The Internet is an essential tool in our lives, but at the same time, it poses significant risks. Governments and companies actively fight against cyber threats and try to protect their users and assets, and you should do the same.

If you prefer the video version, here is the link 😉:
{% embed https://www.youtube.com/watch?v=oy1I02V4JKs&ab_channel=TechVision %}


## What's a proxy server?

Using a Proxy Server is one way to make the Internet safer for users. In networking terms, a client sends a request to a server. For example, when you type a URL in your browser, your browser is the client, and the server is the web server that hosts the website you want to visit. 

![Client Server communication flow animation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrpu070u6trh70xnyt04.gif)

> A proxy server acts as a middleman between the client and the server. 

It forwards the request from the client to the web server and sends the response back to the client via the proxy server.

![Client Server communication through Proxy flow animation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtwv97r7o2laxvrwt5xf.gif)

## How does a proxy server protect you?


A proxy server can be configured to filter the network traffic. For example, it can detect malicious content and block it. It can also block access to certain websites or categories of websites that are deemed malicious or inappropriate. A proxy server used to protect the client is called a **forward proxy**. You'll see later that there is another type of proxy server. 

![Forward proxy animation flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k64qe630feoq0tinpstq.gif)


On top of that, it would be hard for an attacker to target you personally. As far as the external network is concerned, you don't exist. Only the proxy is visible. The proxy server gives you an additional layer of security and privacy. 

Moreover, the proxy server can even increase the speed of your requests. It can [cache](https://dev.to/techvision/make-your-app-faster-use-caching-2f6d) the responses from the server and serve them directly to the client. Your request doesn't have to go all the way to the server and back.

## Does a proxy server give you freedom?

But you could be in a context where you feel like some content is unfairly restricted or censored. In that case, you could use a proxy server to bypass the censorship. Instead of sending the request directly to the server, you send it to the proxy server, which forwards it to the server. As long as the proxy server itself is not blocked, you can access the restricted content.

![Bypass Restriction through proxy server animation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcokp5x9tpz6uynl4nif.gif)


A proxy server can bypass restrictions, but it can also monitor and log user activity. Activity logs can be collected for compliance, auditing, analytics, security monitoring, etc. The critical point is that if you go through a proxy, ensure it's trustworthy and understand how your data is used.

A forward proxy server protects internal clients from external threats, but what about the other way around? What if you want to protect your server from external clients?

## Do proxy servers only protect clients?

Indeed, you can apply the same principle. You would have a Proxy server that sits between the server and the client. This time, the proxy server is called a **reverse proxy**.

![Reverse Proxy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnyph68gett92kefjx55.png)

Since the reverse proxy server is the only one visible from the outside, that's where you can put your security measures to protect the servers in the internal network. The reverse proxy server can be used to block malicious content and detect/prevent cyber attacks like DDoS. NGINX and Cloudflare are examples of providers of reverse proxy servers that are very popular and provide such features.

## Reverse proxies are  not just about security

But on top of security, reverse proxy servers can also improve system performance. They can cache the responses from the internal servers and serve them directly to the client. However, the reverse proxy server cannot cache all types of responses. In those situations where you can't rely on caching, you could use more than one server to handle the load. Guess what? A reverse proxy can route the requests to the different servers and act as a load balancer.

 --- 

Proxy servers are incredibly versatile and can enhance the client's and server's security and performance. They are essential in any network. Understanding this concept is fundamental because it forms the basis of many other concepts, such as CDN, load balancer, microservices gateway services, and many more.