In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Varnish cache proxy varnish cache is the web application accelerator as well as the http reverse cache proxy. You can install varnish on the front end of any http and configure it to cache content. Compared with the traditional squid, varnish has many advantages, such as higher performance, faster speed, more convenient management and so on. Varnish complete configuration instance 1, topology environment Varnish:192.168.31.250Web01:192.168.31.83Web02:192.168.31.141 configuration web01, web02 as the back-end server (process brief) to ensure that the varnish server can normally access web01, web02Varnish cache proxy server configuration:
Install varnish
1. Install the dependency software package (Note: use centos online yum source)
[root@varnish ~] # yum-y install autoconf automake libedit-devel libtool ncurses-devel pcre-devel pkgconfig python-docutils python-sphinx
2. Install varnish
The official website of Varnish is http://varnish-cache.org, where you can download the latest version of the software.
Download address: https://www.varnish-cache.org/content/varnish-cache-403
Note: Varnish sites are sometimes walled.
Git download: git clone https://github.com/varnish/Varnish-Cache / var/tmp/
Decompress and enter the decompression directory to compile and install:
[root@varnish ~] # tar zxf varnish-4.0.3.tar.gz [root@varnish ~] # cd varnish-4.0.3/ [root@varnish varnish-4.0.3] # export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Note:
. / autogen.sh
If you only need to run the installation package downloaded from the Git library, it is used to generate the configure compilation file.
Configuration:
[root@varnish varnish-4.0.3] #. / configure
Note: do not specify the installation path, the default is to install in the / usr/local directory
Compile, install
[root@varnish varnish-4.0.3] # make & & make install
Copy the vcl file (in the compiled installation directory), if there is no default.vcl file in the installation directory.
Copy to the / usr/local/var/varnish/ directory of the installation directory (of course, it is not required to be in that directory, because the official
You also have to specify the directory of this file at startup)
[root@varnish varnish-4.0.3] # cp etc/example.vcl / usr/local/var/varnish/default.vcl
Configure default.vcl
[root@varnish varnish-4.0.3] # vim / usr/loacl/var/varnish/default.vclvcl 4.0: import directors;import std;probe backend_healthcheck {.url = "/"; .interval = 5s; .timeout = 1s; .window = 5; .threshold = 3;} backend web_app_01 {.host = "192.168.164.10"; # to change .port = "80"; .first _ byte_timeout = 9s .connect _ timeout = 3s; .between _ bytes_timeout = 1s; .probe = backend_healthcheck;} backend web_app_02 {.host = "192.168.164.20"; # to change .port = "80"; .first _ byte_timeout = 9s; .connect _ timeout = 3s; .between _ bytes_timeout = 1s; .probe = backend_healthcheck;} acl purgers {"127.0.0.1"; "localhost" "192.168.164.0 sub vcl_recv 24"; # add network segment} sub vcl_init {new web = directors.round_robin (); web.add_backend (web_app_01); web.add_backend (web_app_02);} sub vcl_recv {set req.backend_hint = web.backend () If (req.method = = "PURGE") {if (! client.ip ~ purgers) {return (synth (405, "Not Allowed."));} return (purge) } if (req.method! = "GET" & & req.method! = "HEAD" & & req.method! = "PUT" & & req.method! = "POST" & & req.method! = "TRACE" & & req.method! = "OPTIONS" & & req.method! = "PATCH" & & req.method! = "DELETE") {return (pipe);} if (req.method! = "GET" & & req.method! = "HEAD") {return (pass) } if (req.url ~ "\. (php | asp | aspx | jsp | do | ashx | shtml) ($|\?) {return (pass);} if (req.http.Authorization) {return (pass);} if (req.http.Accept-Encoding) {if (req.url ~"\. (bmp | png | gif | jpg | jpeg | ico | gz | bz2 | tbz | zip | rar | mp3 | mp4 | ogg | swf | flv) $") {flv} unset req.http.Accept-Encoding; (unset req.http.Accept-Encoding; ~" unset req.http.Accept-Encoding; ") {unset req.http.Accept-Encoding; =" unset req.http.Accept-Encoding; ") } elseif (req.http.Accept-Encoding ~ "deflate") {set req.http.Accept-Encoding = "deflate";} else {unset req.http.Accept-Encoding;}} if (req.url ~ "\. (css | js | html | htm | bmp | png | gif | jpeg | ico | gz | tgz | bz2 | tbz | zip | rar | mp3 | mp4 | ogg | swf | flv) ($|\) ($|\?) {unset req.http.cookie;return (hash);} if (req.restarts = 0) {if (req.http.X-Forwarded-For) {req.http.X-Forwarded-For = req.http.X-Forwarded-For +", "+ set req.http.X-Forwarded-For" } else {set req.http.X-Forwarded-For = client.ip;}} return (hash);} sub vcl_hash {hash_data (req.url); if (req.http.host) {hash_data (req.http.host);} else {hash_data (server.ip);} return (lookup);} sub vcl_hit {if (req.method = = "PURGE") {return (synth (200," Purged. "));} return (deliver) } sub vcl_miss {if (req.method = = "PURGE") {return (synth (404, "Purged."));} return (fetch);} sub vcl_deliver {if (obj.hits > 0) {set resp.http.X-Cache = "HIT"; set resp.http.X-Cache-Hits = obj.hits;} else {set resp.http.X-Cache = "MISS";} unset resp.http.X-Powered-By;unset resp.http.Server;unset resp.http.X-Drupal-Cache Unset resp.http.Via;unset resp.http.Link;unset resp.http.X-Varnish;set resp.http.xx_restarts_count = req.restarts;set resp.http.xx_Age = resp.http.Age;set resp.http.hit_count = obj.hits;unset resp.http.Age;return (deliver);} sub vcl_pass {return (fetch);} sub vcl_backend_response {set beresp.grace = 5m If (beresp.status = = 499 | | beresp.status = = 404 | | beresp.status = 502) {set beresp.uncacheable = true;} if (bereq.url ~ "\. (php | jsp) (\? | $)") {set beresp.uncacheable = true;} else {if (bereq.url ~ "\. (css | js | html | htm | bmp | png | gif | jpg | jpeg | ico) ($|\?) {set beresp.ttl = 15mscape unset beresp.http.Set-Cookie;} elseif (bereq.url ~"\. (gz | tgz | bz2 | tbz | zip | rar | mp3 | mp4 | mp4) ($|\?) ") {ogg = 30m Unset beresp.http.Set-Cookie;} else {set beresp.ttl = 10m political unset beresp.http.Set-Cookie;}} return (deliver);} sub vcl_purge {return (synth (200," success "));} sub vcl_backend_error {if (beresp.status = = 500 | | beresp.status = = 501 | | beresp.status = = 502 | | beresp.status = = 503 | | beresp.status = = 504) {return (retry);}} sub vcl_fini {return (ok) } * * launch varnish** [root@varnish ~] # / usr/local/sbin/varnishd-f / usr/local/var/varnish/default.vcl-smalloc,200M-a 0.0.0.0usr/local/sbin/varnishd 80 [root@varnish ~] # netstat-anpt | grep 80
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.