How to install varish as a cache and proxy

  
 1, Varish use two modes: the first Nginx (load) + varish (cache) + WEB second Varish (cache and load) + web 2, varish is based on memory as a shared container: the size of the memory Its cache capacity. It is much more efficient than Squid, which is mainly stored on a hard disk. It is suitable for some static content caches that are frequently queried and do not change much. Nginx images and static text to varish The backend is WEB's 8080 port dynamic content to the backend WEB. The backend is WEB's 8080 port. This architecture depends on the server and storage content. If nginx does not need to do reverse proxy to support many applications in the background, So for nginx alone, the local cache can also be supported with the proxy_cache module. It is cached on the hard drive, performance and squid are not much different, but stability and ease of use are much better. 3, install varish: 1) create users and groups, give permissions groupadd wwwuseradd -g www wwwmkdir -p /car/vcachechown -R www:www /var/vcache 2) create varnish log directory and authorize mkdir -p /var/log /varnishchmod +w /var/log/varnishchown -R www:www /var/log/varnish 3) Compile and install varnishtar zxvf varnish-1.1.2.tar.gzcd varnish-1.1.2./configure --prefix=/usr /local/varnishmake && make install 4) Create and modify the configuration file vi /usr/local/varnish/vcl/conf backend default { #reverse proxy request backend IP is 192.168.0.5, 80 port WEB server , can be local, or can be background.host = "192.168.0.151"; .port = "81"; } acl purge { #Allow these three sources of IP to clear the cache through PURGE method"localhost" ; "127.0.0.1"; "192.168.1.0"/24;} sub vcl_recv { if (req.request == "PURGE") { if (!client.ip ~ purge) { error 405 "Not allowed."; #405Error Display} return(lookup); } if (req.http.host ~ "^blog.s135.com") { set Req.backend = default; if (req.request != "GET" && req.request != "HEAD") { return(pipe); } else { return (lookup); } } else { error 404 "Not in cache"; #404Error display return(lookup); }} sub vcl_hit { if (req.request == "PURGE") { set obj.ttl = 0s; error 200 "Purged." ; } sub vcl_miss { if (req.request == "PURGE") { error 404 "Not in cache."; }} sub vcl_fetch { if (req.request == "GET" && Req.url ~ "/.(txt
Copyright © Windows knowledge All Rights Reserved