All problems in computer science can be solved by another level of indirection.
The idea of proxy is reflected in many fields of computers. In essence, A and B can communicate directly, but we add C as an intermediary, and A and B communicate through C.
Then we can't help but ask: Why do we need to do this? Doesn't this increase the complexity of the system out of thin air? This article will answer this question by explaining the two modes of Forward Proxy and Reverse Proxy in computer networks, and see what benefits the introduction of proxy C will bring us, and also explain its necessity. The article will be explained in the following order:
We know that a complete request is composed of: client -> proxy -> server. Both forward and reverse proxies actually follow this structure and request steps.
Proxies in the direction of the request, that is, the proxy server is configured by the client, serves the client, and requests the target server.
Let's consider the following scenario:
If we need to visit the homepage of GitHub now. However, due to the "wall", we cannot directly access GitHub using the computer. At this time, we can save the country by connecting to a proxy server first. The proxy server forwards our request to GitHub, and then forwards the return of GitHub to us. For GitHub, it doesn't know that we can't actually access it directly.
I know this example doesn't work in most countries, but I'm not sure what websites in your country are inaccessible. Just understand the principle I'm talking about.
The role of Forward Proxy
Access resources that were originally inaccessible.
Can cache and speed up access to resources.
Authorize and authenticate the client access.
The proxy can record the user's access behavior, but hide the user information from the outside.
Unlike the Forward Proxy serving the client, the Reverse Proxy serves the target server. But please note that the request process is still: client -> proxy -> server.
So what problem does the Reverse Proxy solve? Please consider the following scenario:
For Google, there are hundreds of millions of people visiting. A single server must not be able to accept such a large number of requests, and a large amount of network content cannot be stored on the same server. So there must be thousands of different servers inside Google serving users at the same time. So when a user wants to search, how can he know which server the resource he wants to access is on? This is obviously impossible. So all user requests are actually sent to the proxy server of the domain name google.com. The proxy server will forward our request to the corresponding server node, and the node result will be returned to the client again after returning to the proxy server.
For users, You only need to access the proxy server without paying attention to the server that actually provides the response. The proxy server only performs requests and forwarding.
The role of Reverse Proxy
Ensure the security of the intranet. Usually large websites use Reverse Proxy servers as public network access addresses, while their own web servers are intranet environments.
Load balancing. The proxy server can load balance traffic during forwarding.
The Forward Proxy is a proxy facing the client, and the server does not know who the actual requesting client is. The client and the proxy belong to the same LAN.
The Reverse Proxy is a proxy facing the server, and the client does not know who the actual server providing the service is. The server and the proxy belong to the same LAN.