What does reverse proxy mean? What is the difference between forward proxy and reverse proxy?

An article explains clearly the difference between forward proxy and reverse proxy

What is a forward proxy? What is a reverse proxy? What's the difference? It will become clear after reading this article…

First of all, literally speaking, agency means handling on behalf of one party, which means one party entrusts another party to do things. In the world of computer networks, agency usually refers to the intermediary between the client and the server.

Proxies in computer networks are divided into forward proxies and reverse proxies. Forward proxies are very simple, that is, the client does not access the server directly, but accesses it through an intermediary (the intermediary first obtains data from the server on behalf of the client, Then return the obtained data to the client), it is easy to understand, right? Many people will ask, why does the client "take off its pants and fart" instead of directly accessing the server? There are usually two reasons:

1. For some reasons you know, the network where the client is located has restricted access to the server;
2. For some special reasons, the server does not allow clients from certain sources to access.

For example, village A and village B have a bad relationship, so village A has set restrictions and does not allow villager A to buy corn at the commissary of village B, or the commissary of village B does not sell corn to villager A. But villager A wants corn from the commissary of village B, so what should he do? Villager A can entrust people from village C to go to village B to buy things on his behalf, and then give them to him after bringing them back. This is a forward agent. The schematic diagram is as follows:
Insert image description here

Image source: Drawn by myself

The characteristics of this structure are: the server does not know who its real customer is. The customer it contacts is the agent, but the customer knows who is actually providing the service (it is the B commissary rather than the agent). The forward agent is the client. Solution where you cannot directly access (or want to access anonymously) the server, the client is the client!

Regarding reverse proxy, many people find it difficult to understand, because normal thinking is that since the forward proxy is the intermediary for the client to obtain data from the server, then the reverse proxy should naturally be the intermediary for the server to obtain data from the client. Yes, but this is not the case. They are very different. This is the difficulty in understanding. Let’s take a look at the picture below:
Insert image description here

Image source: Drawn by myself

There are many villagers in Village B who produce corn (assuming that the corn produced is indistinguishable), but it is troublesome to sell corn separately, because customers don’t know which one has it, and they don’t know how much which one has, so they entrust them all. Sold to the canteen in Village B (note: the client is the server! ), and the canteen provides unified external services. Customers who buy corn don’t know which company the corn comes from, so they can just buy it directly from the commissary. This is a reverse proxy.

The characteristic of this structure is that the client does not know who is the real server (provider), and the reverse proxy will often forward the request to the most appropriate server for processing according to a certain strategy, such as allocating it according to the server's busy status. , does it sound like a load balancing strategy? Yes, reverse proxy is often used to implement load balancing scenarios. Web servers such as Nginx support the reverse proxy function and are widely used to implement load balancing.

In summary: Although the names of these two proxy methods are similar, their purposes and application scenarios are very different:

  • From a functional point of view:
    Forward proxy is a solution where the client cannot (inconvenience) directly access the server.
    Reverse proxy is a solution where multiple servers provide services to the outside world in a unified manner.
  • From the perspective of the target customer,
    the client of the forward proxy is the client, and the proxy provides services to the client (one at a time). The
    client of the reverse proxy is the server, and the proxy provides services to multiple clients (usually multiple, but it can also be Single) server provides services
  • From the perspective of visibility,
    the forward proxy is visible to the client. It is the result of the client's active selection (optional or not, the server can only passively select). The client can choose to access directly (whether access can be obtained is another matter. ), you can also choose to access
    the reverse proxy through a proxy, which is invisible to the client. It is the result of the client’s passive selection (the result of the server’s active selection), which means: the client does not know whether the service currently being accessed is used. reverse proxy

PS: Sometimes, these two proxy methods coexist in a network request, as shown in the following figure:
Insert image description here

*Picture source: Drawn by myself*

Everyone performs their duties and there is no conflict at all

Friends, do you understand?

Guess you like

Origin blog.csdn.net/one_and_only4711/article/details/117038339