Forward Proxy and Reverse Proxy: Decrypting Two Different Postures of Network Proxy

forward proxy

  • In forward proxying, the proxy server sends requests to the target server on behalf of the client and returns the target server's response to the client. The client usually needs to be configured to use a forward proxy to access external resources, and the target server is not aware of the proxy server.
    insert image description here
    The main features of forward proxy include:
  1. Proxy Client: Initiating a request to the proxy server on behalf of the client. The client knows that it is using a proxy, and it sends the request to the proxy server, which then requests data from the target server on the client's behalf.

  2. Hide the real IP of the client: When the forward proxy server processes the request, it will hide the real IP address of the client, thereby increasing the privacy and security of the client. The target server can only see the IP address of the proxy server and cannot directly identify the real client.

  3. Bypass access restrictions: forward proxy can help clients bypass access restrictions or firewall restrictions. For example, some countries or organizations may restrict access to specific websites or services, but by using a forward proxy, clients can access these restricted resources.

  4. Cache: The forward proxy server can also cache the response of the target server, thereby reducing the traffic of repeated requests, improving access speed, and reducing the burden on the target server.

  • Common example: the network environment of a company or school. If there is a forward proxy server in the network, all client requests need to be sent to the external network through the proxy server. This enables control and monitoring of access to external resources, and can strengthen security controls on clients.

reverse proxy

  • Reverse proxy is a proxy server configuration method, which receives the client's request on behalf of the back-end server, forwards the request to the back-end server, and then returns the response of the back-end server to the client. Contrary to forward proxy**, the client does not know that the backend server is actually handling the request, but thinks that it is directly communicating with the proxy server. **
    insert image description here
    Main features of a reverse proxy include:
  1. Proxy back-end server: The reverse proxy server processes the client's request on behalf of the back-end server. The client does not know the existence of the back-end server, but only knows to communicate with the proxy server. A proxy server acts as a middleman between the client and the backend server.

  2. Hiding the back-end server: By using a reverse proxy, the real IP address and structure of the back-end server can be hidden, which improves the security and privacy protection of the server. The client cannot directly access the backend server, but can only communicate with the proxy server.

  3. Load balancing: The reverse proxy can distribute client requests to multiple backend servers to achieve load balancing. This can improve the performance and reliability of the system, ensure that server resources are used reasonably, and prevent a server from being overloaded.

  4. Cache: The reverse proxy server can cache the response of the back-end server. When multiple clients request the same resource, they can directly return the cached response, reducing the burden on the back-end server and improving response speed and concurrent processing capabilities.

  5. Security filtering: Reverse proxy can be used to implement some security filtering measures, such as blocking access to specific IPs, filtering malicious requests, etc., to protect back-end servers from malicious attacks.

A common example is website load balancing. When a user visits a website, the request is first received by the reverse proxy server, and then the reverse proxy forwards the request to one of the multiple backend servers according to the load balancing algorithm. The backend server processes the request and returns a response to the reverse proxy, which then returns it to the user. Users do not directly contact the backend server, but only communicate with the reverse proxy server.

Summarize

  • Summary: A forward proxy is a proxy server that sends requests on behalf of the client, hides the client's real IP, allows access restrictions to be bypassed, and provides caching. In contrast, a reverse proxy is a proxy server that receives requests on behalf of the server, hides the real IP of the server, and implements functions such as load balancing and security filtering.

Discrimination: The dual identity of nginx

  • In fact, Nginx has dual identities. Nginx can act as a forward proxy and a reverse proxy at the same time, depending on whether it communicates on behalf of the client or the back-end server.
  1. Forward Proxy: Nginx is a forward proxy when it is configured to send requests to an external target server on behalf of the client .

    • In this case, the client knows and realizes that it is sending the request through the proxy server, but the target server does not know the actual client exists because the target server can only see the IP address of the proxy server.
    • This situation is usually used in a local area network or in some specific network environments to control the access rights of clients or bypass access restrictions, such as VPN.
  2. Reverse Proxy: When Nginx is configured to send requests to internal servers on behalf of external clients, it is a reverse proxy .

    • In this case, the client does not know that Nginx is actually processing the request, but thinks that it communicates directly with the target server behind Nginx . Nginx will forward the client's request to multiple internal servers according to the configuration, and return the response to the client after processing.
    • This situation is usually used for load balancing, providing security barriers, hiding backend servers, etc.
  • Nginx is called a reverse proxy server because in most cases, people use Nginx configured as a reverse proxy to handle client requests, communicating with the client on behalf of the back-end server . But in fact, Nginx can also be used as a forward proxy with proper configuration.

Guess you like

Origin blog.csdn.net/yang2330648064/article/details/131563514