Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Varnish implements cache acceleration

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Varnish implements cache acceleration

1. Using varnish to implement cache acceleration for nginx

1. Experimental environment:

(1) one varnish cache server and one nginx server

(2) turn off the firewall and selinux

two。 Configure varnish

(1) modify the varnish configuration file:

Create a directory: mkdir-pv / data/varnish/cache modify owner: chown varnish.varnish / data/varnish/cache

(2) Test:

Second, varnish realizes the separation of dynamic and static.

(1) varnish configuration:

(2) Test:

(3) set multiple groups in the attachment content and do the load:

Example: import directors backend imgsrv1 {.host = "192.168.10.11"; .port = "80";} backend imgsrv2 {.host = "192.168.10.12"; .port = "80";} backend appsrv1 {.host = "192.168.10.21"; .port = "80" } backend appsrv2 {.host = "192.168.10.22"; .port = "80";} sub vcl_init {new imgsrvs = directors.random (); imgsrvs.add_backend (imgsrv1,10); imgsrvs.add_backend (imgsrv2,20); new staticsrvs = directors.round_robin (); appsrvs.add_backend (appsrv1); appsrvs.add_backend (appsrv2) New appsrvs = directors.hash (); appsrvs.add_backend (appsrv1,1); appsrvs.add_backend (appsrv2,1);} sub vcl_recv {if (req.url ~ "(? I)\. (css | js) $" {set req.backend_hint = staticsrvs.backend () } if (req.url ~ "(?)\. (jpg | jpeg | png | gif) $" {set req.backend_hint = imgsrvs.backend ();} else {set req.backend_hint = appsrvs.backend (req.http.cookie);}}

Security Inspection:

.probe: define the health status detection method; .url: the URL to be requested when testing. Default is "/"; .request: the specific request issued. .request = "GET / .healthtest.html HTTP/1.1", "Host: www.ww.com", "Connection: close" .window: judge its health status based on the number of recent checks Threshold: among the most recent checks defined in .window, the number of times defined by threshold hhold is successful; success threshold; .interval: detection frequency; .timeout: timeout; .timeout: expected response code. Default is 200. Configuration of health status detection: probe PB_NAME {} backend NAME = {.probe = PB_NAME;.}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report