Case 1, Reverse proxy
Goal:
1. The proxy server can cache remote Web Server Pages locally
2. Proxy server port set to 80 port
3. Users can get the content on the Remote Web server page by accessing the proxy server
4. The remote Web server is transparent to the client user
5. Using caching mechanism to improve website response speed
Scheme:
Using 3 RHEL7 virtual machine, one as Squid Proxy server, need to configure two network cards (connect different network segments), the address is 192.168.4.5, 192.168.2.5. One as a client test host with an IP address of 192.168.4.100. One as a Web server with an IP address of 192.168.2.100, which provides a Web service data source for the proxy server.
The IP Configuration & network topology is as follows:
Steps:
Create 3 virtual Machines--->3 virtual machines are client (client), proxy (proxy server), WEB1 (server)--->3 virtual machine respectively, configure IP, build Yum warehouse, set up automatic mount, modify login password (simplify password)
Web Server Build:
Yum installs httpd and provides Web services: Yum-y Install httpd
Start the httpd service, set the boot: Systemctrl restart Httpd;systemctrl enable httpd
View the status of Port number 80 (httpd by default with 80 ports): NETSTAT-ANTPU |grep 80
Create a Web server test file: echo "Hello the World" >/var/www/html/index.html
Squid Proxy Server Deployment:
Yum installs Squid and provides proxy services: Yum-y install Squid
1> modifying configuration file/etc/squid/squid.conf : Set nu setting line number
...........
Http_access allow all allows all hosts in the machine to use a proxy server
Http_port vhost set up reverse proxy, port number
Visible_hostname www.sina.com Set host name, default does not have this line, need to add manually, host name can be set by itself
Cache_peer 192.168.2.11 Parent 0 originserver define back-end real server information, 80 is the httpd port number, 0 would have been to ICMP port number, not here, but to preserve the format must write 0
Cache_dir Ufs/var/spool/squid to Cancel comments to take effect , hard disk cache, cache 100M, automatically create 16 levels of 1 subdirectories and 256 levels of 2 sub-directories
2> Start squid service, set to boot: Systemctrl restart squid; Ystemctrl Enable Squid
3> View port number 80 status to see if the service is started, Squid service listens for client requests via TCP 80 port by default: NETSTAT-ANTPU |grep 80
Client testing:
[[Email protected] Client ~]# Curl http://192.168.4.5 Access Proxy Address page to test whether the Squid Proxy server was successfully built
[[Email protected] Client ~]# curl-i http://192.168.4.5 can view page details, if not first access, will show hit cache hits, if the first access, will show Miss no cache , but the next visit will hit you.
Case 2, using varnish to accelerate the web
Goal:
1. Using varnish to accelerate the backend Apache Web service
2. Manage cache pages using the VARNISHADM command
3. Use the Varnishstat command to view the varnish status
Scheme:
Installing the varnish cache server through source compilation
1. Compile and install varnish software
2. Copying startup scripts and configuration files
Modify the configuration file, cache the proxy source Web server, and implement the Web Acceleration feature
Use 3 RHEL7 virtual machines, one as a Web server (192.168.2.100), one as a varnish proxy server (192.168.4.5,192.168.2.5), Another Linux client for testing (192.168.2.100)
For the deployment of the Web server, this experiment only needs to install the HTTPD software, start the service, and generate the test home file, the default httpd site root path is/var/www/html, the first page document name is index.html.
Steps:
Create 3 virtual Machines--->3 virtual machines are client (client), proxy (proxy server), WEB1 (server)--->3 virtual machine respectively, configure IP, build Yum warehouse, set up automatic mount, modify login password (simplify password)
Web Server Build:
Yum installs httpd and provides Web services: Yum-y Install httpd
Start the httpd service, set the boot: Systemctrl restart Httpd;systemctrl enable httpd
View the status of Port number 80 (httpd by default with 80 ports): NETSTAT-ANTPU |grep 80
Create a Web server test file: echo "Hello the World" >/var/www/html/index.html
Varnish deployment of proxy servers:
Configuration file:
/etc/sysconfig/varnish [Front-end Client access configuration file]
/ETC/VARNISH/DEFAULT.VCL [Backend server-side provisioning profile]
Front-end file: (black for corrected file, cyan for original reference file)
varnish_listen_port=80 #VARNISH侦听端口号80
varnish_storage_size=64m #后面更改了缓存储存在内存里, stored in memory, can speed up the response, where appropriate cache size adjustment, according to the size of the memory to set
Varnish_storage= "Malloc,${varnish_storage_size}" #将缓存该为内存存储
varnish_admin_listen_address=127.0.0.1 #本机循环IP地址
varnish_admin_listen_port=6082 #本机管理员端口号
Varnish_storage_file=/var/lib/varnish/varnish_storage.bin #VARNISH缓存为文件格式时缓存位置, bit and on hard disk
varnish_storage_size=1g #VARNISH为文件格式存储在硬盘上时, default cache size is 1G
Varnish_storage= "File,${varnish_storage_file},${varnish_storage_size}" #VARNISH定义为文件格式储存, slow existence on the hard disk
Client testing:
[[Email protected] Client ~]# Curl http://192.168.4.5 Access Proxy Address page to test whether the Squid Proxy server was successfully built
[[Email protected] Client ~]# curl-i http://192.168.4.5 can view page details, if not first access, will show hit cache hits, if the first access, will show Miss no cache , but the next visit will hit you.
Advanced Operations (i): Reverse proxy & Use varnish to accelerate the web