Forward proxy and direction code 【Summary】

1 Introduction

  Recently, I used reverse proxy in my work, and found that there are quite a lot of ways to play network proxy, and there is a lot to learn behind the network. Before that, only proxy software was used. In order to access google, proxy software was used, and the address of the proxy needed to be configured in the browser. I only know the concept of agency, and I don’t know that there are forward and reverse agents, so I hurried to learn and supplement my knowledge. First figure out what is a forward proxy and what is a reverse proxy, then how the two are shown in actual use, and finally summarize what the forward proxy is used for and what the reverse proxy can do.

2. Forward proxy

  The forward proxy is like a springboard machine, and the proxy accesses external resources.

for example:

  I am a user, I cannot access a certain website, but I can access a proxy server, what about this proxy server, he can access the website that I cannot access, so I connect to the proxy server first, and tell him that I need the website that cannot be accessed content, the proxy server fetches it back, and then returns it to me. From the perspective of the website, there is only one record when the proxy server fetches the content. Sometimes it is not known that it is the user's request, and the user's information is also hidden. It depends on whether the proxy tells the website.

  The client must set up a forward proxy server, of course, the premise is to know the IP address of the forward proxy server and the port of the proxy program.

  For example, if you have used such software such as CCproxy before, http://www.ccproxy.com / needs to configure the proxy address in the browser.

  To sum up: the forward proxy is a server located between the client and the original server (origin server). The server forwards the request and returns the obtained content to the client. The client must make some special settings to use the forward proxy.

  The purpose of forward proxy:

  (1) Access resources that were previously inaccessible, such as google

     (2) It can be cached to speed up access to resources

  (3) Authorize client access and authenticate online

  (4) The agent can record user access records (online behavior management) and hide user information from the outside world

For example CCProxy uses:

3. Reverse proxy

  The feeling of contacting the direction proxy for the first time is that the client is unaware of the existence of the proxy, and the reverse proxy is transparent to the outside world, and the visitor does not know that he is visiting a proxy. Because the client can access without any configuration.

  The actual operation mode of reverse proxy (Reverse Proxy) is to use the proxy server to accept the connection request on the Internet, then forward the request to the server on the internal network, and return the result obtained from the server to the client requesting the connection on the Internet At this time, the proxy server acts as a server externally.

The role of reverse proxy:

(1) To ensure the security of the intranet, reverse proxy can be used to provide WAF function to prevent web attacks

For large websites, the reverse proxy is usually used as the public network access address, and the web server is the intranet.

(2) Load balancing, optimize the load of the website through the reverse proxy server

4. The difference between the two

Borrow two pictures from Zhihu to express: Why is a reverse proxy called a reverse proxy? - Know almost

5. Reverse proxy of nginx

   Nginx supports the configuration of reverse proxy to achieve load balancing of websites through reverse proxy. This part first writes an nginx configuration, and then needs to study the proxy module and load balancing module of nginx in depth.

Nginx configures the proxy site through proxy_pass_http, and upstream implements load balancing.

Guess you like

Origin blog.csdn.net/weixin_45925028/article/details/132318113