rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.el5.centos.noarch.rpm
yum install varnish
rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm
yum install varnish
error: Failed dependencies:
rpmlib(FileDigests) <= 4.6.0-1 is needed by varnish-release-3.0-1.el6.noarch
rpmlib(PayloadIsXz) <= 5.2-1 is needed by varnish-release-3.0-1.el6.noarch
Error: Missing Dependency: libedit.so.0 is needed by package varnish-3.0.5-1.el5.centos.i386 (varnish-3.0)
rpm -ivh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.1-1.el5.rf.i386.rpm (32位)
rpm -ivh http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm (64位)
yum clean allyum update
curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add -echo "deb http://repo.varnish-cache.org/debian/ wheezy varnish-3.0" >> /etc/apt/sources.list
apt-get update
apt-get install varnish
curl http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add -echo "deb http://repo.varnish-cache.org/ubuntu/ precise varnish-3.0" | sudo tee -a /etc/apt/sources.listsudo
apt-get updatesudo
apt-get install varnish
- # This is a basic VCL configuration file for varnish. See the vcl(7)
- # man page for details on VCL syntax and semantics.
- # Default backend definition. Set this to point to your content
- # server.
- backend default {
- .host = "127.0.0.1";
- .port = "8080";
- }
- acl purge {
- "localhost";
- "127.0.0.1";
- }
- # Below is a commented-out copy of the default VCL logic. If you
- # redefine any of these subroutines, the built-in logic will be
- # appended to your code.
- sub vcl_recv {
- # Only cache the following site
- if (req.http.host ~ "(amhg.freehao123.info)") {
- set req.backend = default;
- } else {
- return (pass);
- }
- if (req.request == "PURGE") {
- if (!client.ip ~ purge) {
- error 405 "Not allowed.";
- }
- return (lookup);
- }
- if (req.restarts == 0) {
- if (req.http.x-forwarded-for) {
- set req.http.X-Forwarded-For =
- req.http.X-Forwarded-For + ", " + client.ip;
- } else {
- set req.http.X-Forwarded-For = client.ip;
- }
- }
- if (req.request != "GET" &&
- req.request != "HEAD" &&
- req.request != "PUT" &&
- req.request != "POST" &&
- req.request != "TRACE" &&
- req.request != "OPTIONS" &&
- req.request != "DELETE") {
- /* Non-RFC2616 or CONNECT which is weird. */
- return (pipe);
- }
- if (req.request != "GET" && req.request != "HEAD") {
- /* We only deal with GET and HEAD by default */
- return (pass);
- }
- if (req.http.Authorization || req.http.Cookie ~ "wordpress_logged" || req.http.Cookie ~ "comment_") {
- /* Not cacheable by default */
- return (pass);
- }
- return (lookup);
- }
- sub vcl_pipe {
- # Note that only the first request to the backend will have
- # X-Forwarded-For set. If you use X-Forwarded-For and want to
- # have it set for all requests, make sure to have:
- # set bereq.http.connection = "close";
- # here. It is not set by default as it might break some broken web
- # applications, like IIS with NTLM authentication.
- return (pipe);
- }
- sub vcl_pass {
- return (pass);
- }
- sub vcl_hash {
- hash_data(req.url);
- if (req.http.host) {
- hash_data(req.http.host);
- } else {
- hash_data(server.ip);
- }
- return (hash);
- }
- sub vcl_hit {
- if (req.request == "PURGE") {
- purge;
- error 200 "Purged.";
- }
- return (deliver);
- }
- sub vcl_miss {
- if (req.request == "PURGE") {
- purge;
- error 200 "Purged.";
- }
- return (fetch);
- }
- sub vcl_fetch {
- if (beresp.ttl <= 0s ||
- beresp.http.Set-Cookie ||
- beresp.http.Vary == "*") {
- /*
- * Mark as "Hit-For-Pass" for the next 2 minutes
- */
- set beresp.ttl = 120 s;
- return (hit_for_pass);
- }
- set beresp.ttl = 1d;
- return (deliver);
- }
- sub vcl_deliver {
- return (deliver);
- }
- sub vcl_error {
- set obj.http.Content-Type = "text/html; charset=utf-8";
- set obj.http.Retry-After = "5";
- synthetic {"
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html>
- <head>
- <title>"} + obj.status + " " + obj.response + {"</title>
- </head>
- <body>
- <h1>Error "} + obj.status + " " + obj.response + {"</h1>
- <p>"} + obj.response + {"</p>
- <h3>Guru Meditation:</h3>
- <p>XID: "} + req.xid + {"</p>
- <hr>
- <p>Varnish cache server</p>
- </body>
- </html>
- "};
- return (deliver);
- }
- sub vcl_init {
- return (ok);
- }
- sub vcl_fini {
- return (ok);
- }
| 欢迎光临 冠富商务通中文社区 (http://gu1vhwx.nat.ipyingshe.com/news/) | Powered by Discuz! 3.0 |