Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

16.4 Reverse proxy


May 24, 2021 That's what Linux should learn



Site pages are composed of static resources and dynamic resources, including site architecture CSS files, a large number of pictures, videos and other data, these data is more stable than dynamic resources, generally do not change often. H owever, with the upgrading of station technology, coupled with people's increasing aesthetic ability, these static resources occupy more and more site space. If you can pull these static resources out of the site page and then deploy cache nodes of static resources across the country, this will not only speed up users' access to the site, but also reduce the load on the site source server because of the presence of these cache nodes.

Reverse proxy is an important pattern of Squid service programs, based on the principle of handing over a portion of user requests originally initiated to the site source server to the Squid server cache node for processing. B ut the drawbacks of this technology are also obvious, if there are people who have the right to reverse their domain name and server to a well-known website, in theory, when users access the domain name, they will also see the same content as that well-known website (some scam sites are such as tricking users into trusting). A s a result, many websites currently disable reverse proxy by default. W ebsites that have CDN (Content Distribution Network) services turned on can also avoid this theft. If you visit a website with protection turned on, you'll generally see the error message shown in Figure 16-16.

16.4 Reverse proxy

Figure 16-16 When visiting a website, you are prompted to report an error message

Mr. Liu Wei temporarily closed the CDN service and protection plug-in of this book supporting the site in order to meet the needs of the experiment, please try to choose your own website or blog to carry out the experimental operation, to avoid affecting the normal operation of other sites, causing trouble to others.

Using the Squid service provider to configure the reverse proxy service is simple. F irst find the IP address of the site source server, then edit the main profile of the Squid service provider, change port number 3128 to the address and port number of the site source server, at which point the forward resolution service is suspended (it cannot be used in the same way as the reverse proxy service). T hen write the IP address information of the source server of the website that needs the reverse proxy in the form of the following parameters, save the exit and restart the Squid service program. The effect of using reverse proxy services on normal websites is shown in Figure 16-17.

[root@linuxprobe ~]# vim /etc/squid/squid.conf .................. O mit some of the output information... 5 7 58 squid normally listens to port 3128 59 http_port Your bridge card IP address: 80 vhost 60 cache_peer website source server IP address parent 80 0 originserver 61 ... O mit some of the output information... [root@linuxprobe ~]# systemctl restart squid

16.4 Reverse proxy

Figure 16-17 uses reverse proxy mode to access websites