Detailed explanation of forward proxy and reverse proxy

1. Forward proxy

1.1 Concept

A forward proxy is a proxy server (intermediate server) that sits between the client and the target server. In order to obtain content from the target server, the client sends a request to the proxy server and specifies the target server , and then the proxy forwards the request to the target server and returns the obtained content to the client. In the case of a forward proxy, the client must perform some special settings before it can be used.

1.2 Features

  • The forward proxy needs to actively set the proxy server ip or domain name to access, and the set server ip or domain name will access the content and return
  • A forward proxy is a proxy client that sends and receives requests for the client, making the real client invisible to the server.

insert image description here

1.3 Usage Scenarios

The typical use of a forward proxy is to provide a way for LAN clients inside the firewall to access the server. The forward proxy can also use the buffering feature to reduce network utilization.

  • Scientific Internet (over the wall)

Sometimes, users want to visit a foreign website, which cannot be accessed directly in China, but we can access a proxy server, and this proxy server can access this foreign website. In this way, the user's access to the foreign website needs to forward the request through the proxy server, and the proxy server will also return the response to the request to the user. This process of surfing the Internet uses a forward proxy.

insert image description here

1.4 Purpose

  • Breakthrough access display : Through the proxy server, you can break through your own ip access restrictions and visit foreign websites, etc.
  • Improve access speed : Usually, the proxy server sets a large hard disk buffer, which will save the response of some requests in the buffer. When other users access the same information again, the information will be directly taken out from the buffer and passed to the buffer. users to improve access speed
  • Hide the real ip of the client : Internet users can hide their ip through the forward proxy method to avoid attacks

2. Reverse proxy

2.1 Concept

Reverse proxy refers to using a proxy server to receive the client's request, then forward the request to the server on the internal network, and return the result obtained from the server to the client. At this time, the proxy server acts as a reverse proxy server externally.

For the client, the reverse proxy is equivalent to the target server. It only needs to send the request as the target server, and the client does not need to make any settings.

2.2 Features

  • The forward proxy needs to configure the proxy server, but the reverse proxy does not need to do any settings.
  • A reverse proxy is a proxy server that sends and receives requests for the server, making the real server invisible to the client.

insert image description here

2.3 Usage Scenarios

The typical use of a reverse proxy is to provide servers outside the firewall for client access. The reverse proxy can also provide load balancing for multiple back-end servers, or provide buffering services for slower back-end servers.

insert image description here

2.4 Purpose

  • Hide the real ip of the server : use a reverse proxy to hide the ip address of the server from the client
  • Load balancing : the reverse proxy server can do load balancing, and distribute client requests to different real servers according to the load conditions of all real servers
  • Improve access speed : the reverse proxy server can provide caching services for static content and dynamic content with a large number of access requests in a short period of time, improving access speed
  • Provide security : the reverse proxy server can be used as an application layer firewall to provide websites with protection against web-based attacks (such as DoS/DDoS), and it is easier to troubleshoot malware. It can also provide unified encryption and SSL acceleration (such as SSL terminal proxy) for the back-end server, and provide HTTP access authentication, etc.

3. Similarities and differences between forward proxy and reverse proxy

3.1 Similarities

The forward proxy and reverse proxy are located between the client and the real server, and what they do is to forward the client's request to the server, and then forward the server's response to the client.

3.2 Differences

  • The forward proxy is the proxy of the client , and the server does not know who the real client is; the reverse proxy is the proxy of the server , and the client does not know who the real server is
  • The forward proxy is generally set up by the client ; the reverse proxy is generally set up by the server
  • The forward proxy is mainly used to solve the access restriction problem ; the reverse proxy is to provide load balancing, security protection and other functions. Both can improve access speed

4. Understand forward proxy and reverse proxy through stories

4.1 Forward Proxy

Classmate A needed a sum of money urgently. He borrowed money directly from the rich man Jack Ma, but they had nothing to do with each other, so of course he didn't get the loan. After some inquiries, classmate A’s teacher, Mr. Wang, is Ma Yun’s good friend, so classmate A asked Mr. Wang to help him borrow money from Ma Yun. Finally, Ma Yun agreed to lend money to Mr. Wang, and Mr. Wang transferred the money to Mr. Wang. Classmate A.

The above is equivalent to a forward proxy process, student A is the client, Ma Yun is the server, and Mr. Wang is the forward proxy. Student A asked Mr. Wang to borrow money from Ma Yun. During this process, student A concealed his role. In fact, Ma Yun did not know who borrowed the money. It is equivalent to that the server does not know who the client who actually initiated the request is.

4.2 Reverse proxy

If you encounter difficulties, you need to call 10086 customer service. There may be dozens of 10086 customer service in an area, but we don't need to care about who is on the other end of the phone. Just dial the switchboard number 10086, and there will always be customer service on the other end of the phone.

The 10086 switchboard number here is equivalent to a reverse proxy, and the client does not know who is actually providing the service.

reference documents

The difference between forward proxy and reverse proxy - Programmer Sought

Finally someone explained the forward proxy and reverse proxy clearly!

Guess you like

Origin blog.csdn.net/Dax1_/article/details/124652162