{"id":17480,"date":"2022-10-18T05:04:40","date_gmt":"2022-10-17T21:04:40","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=17480"},"modified":"2022-10-18T05:05:39","modified_gmt":"2022-10-17T21:05:39","slug":"varnish-installation-configuration","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/varnish-installation-configuration.html","title":{"rendered":"\u9ad8\u6027\u80fdHTTP\u52a0\u901f\u5668Varnish\u5b89\u88c5\u4e0e\u914d\u7f6e"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nVarnish\u662f\u4e00\u6b3e\u9ad8\u6027\u80fd\u4e14\u5f00\u6e90\u7684\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u548cHTTP\u52a0\u901f\u5668\uff0c\u5b83\u91c7\u7528\u4e86\u5168\u65b0\u7684\u8f6f\u4ef6\u4f53\u7cfb\u7ed3\u6784\uff0c\u548c\u73b0\u5728\u7684\u786c\u4ef6\u4f53\u7cfb\u914d\u5408\u7d27\u5bc6\u3002\u4e0b\u9762\u5c31\u7531\u6211\u7ed9\u5927\u5bb6\u7b80\u5355\u8bf4\u8bf4\u4ed6\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5b89\u88c5<\/strong><\/div>\n
\u5b89\u88c5pcre<\/strong><\/span><\/div>\n

\u5982\u679c\u6ca1\u6709\u5b89\u88c5pcre,\u5728\u7f16\u8bd1varnish 2.0\u4ee5\u4e0a\u7248\u672c\u65f6\uff0c\u4f1a\u63d0\u793a\u627e\u4e0d\u5230pcre\u5e93\uff0c\u800cpcre\u5e93\u662f\u4e3a\u4e86\u517c\u5bb9\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u6240\u4ee5\u5fc5\u987b\u5148\u5b89\u88c5pcre\u5e93\u3002\u4e0b\u9762\u662fpcre\u7684\u5b89\u88c5\u8fc7\u7a0b\uff1a<\/p>\n

[root@varnish-server ~]# tar -zxvf pcre-7.9.tar.gz\r\n[root@varnish-server ~]# cd pcre-7.9\/\r\n[root@varnish-server ~]# .\/config  --prefix=\/usr\/local\/pcre\/\r\n[root@varnish-server ~]# make && make install<\/pre>\n
\u5b89\u88c5Varnish<\/strong><\/span><\/div>\n

\u8fd9\u91cc\u5c06Varnish\u5b89\u88c5\u5230\/usr\/local\/\u76ee\u5f55\u4e0b\uff0c\u64cd\u4f5c\u5982\u4e0b\uff1a<\/p>\n

[root@varnish-server ~]# tar -zxvf varnish-2.1.2.tar.gz\r\n[root@varnish-server ~]# cd varnish-2.1.2\r\n[root@varnish-server ~]# export PKG_CONFIG_PATH=\/usr\/local\/pcre\/lib\/pkgconfig\r\n[root@varnish-server ~]# .\/configuer  --prefix=\/usr\/local\/varnish \\\r\n>--enable-dependency-tracking\r\n>--enable-debugging-symbols\r\n>--enable-developer-warnings\r\n[root@varnish-server ~]# make\r\n[root@varnish-server ~]# make install\r\n[root@varnish-server ~]# cp redhat\/varnish.initrc   \/etc\/init.d\/varnish\r\n[root@varnish-server ~]# cp redhat\/varnish.sysconfig  \/etc\/syscinfug\/varnish<\/pre>\n

\u5176\u4e2d\uff0c\u201cPKG_CONFIG_PATH\u201d\u662f\u6307\u5b9aVarnish\u67e5\u627epcre\u5e93\u7684\u8def\u5f84\uff0c\u81f3\u6b64\uff0cVarnish\u5b89\u88c5\u5b8c\u6bd5\u3002<\/p>\n

\u914d\u7f6e<\/strong><\/div>\n

\u7531\u4e8e\u7bc7\u5e45\u9650\u5236\uff0c\u5728\u8fd9\u513f\u662f\u4ecb\u7ecdVCL\u5185\u7f6e\u51fd\u6570\u7684\u610f\u4e49\uff0c\u8bf7\u5927\u5bb6\u89c1\u8c05\uff01<\/p>\n

vcl_recv\u51fd\u6570<\/strong><\/span><\/div>\n

\u7528\u4e8e\u63a5\u53d7\u548c\u5904\u7406\u8bf7\u6c42\u3002\u5f53\u8bf7\u6c42\u8fbe\u5230\u5e76\u88ab\u6210\u529f\u63a5\u6536\u540e\u88ab\u8c03\u7528\uff0c\u901a\u8fc7\u5224\u65ad\u8bf7\u6c42\u7684\u6570\u636e\u6765\u51b3\u5b9a\u5982\u4f55\u5904\u7406\u8bf7\u6c42\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

>pass:\u8868\u793a\u8fdb\u5165pass\u6a21\u5f0f\uff0c\u628a\u8bf7\u6c42\u63a7\u5236\u6743\u4ea4\u7ed9vcl_pass\u51fd\u6570\u3002\r\n>pipe\uff1a\u8868\u793a\u8fdb\u5165pipe\u6a21\u5f0f\uff0c\u8bf7\u628a\u8bf7\u6c42\u63a7\u5236\u6743\u4ea4\u7ed9vcl_pipe\u51fd\u6570\u3002\r\n>error code [reason]\uff1a\u8868\u793a\u8fd4\u56de\u201ccode\u201d\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u653e\u5f03\u5904\u7406\u8be5\u8bf7\u6c42\u3002<\/pre>\n
vcl_pipe\u51fd\u6570<\/strong><\/span><\/div>\n

\u6b64\u51fd\u6570\u5728\u8fdb\u5165pipe\u6a21\u5f0f\u65f6\u88ab\u8c03\u7528\uff0c\u7528\u4e8e\u5c06\u8bf7\u6c42\u76f4\u63a5\u4f20\u9012\u81f3\u540e\u7aef\u4e3b\u673a\uff0c\u5728\u8bf7\u6c42\u548c\u8fd4\u56de\u7684\u5185\u5bb9\u6ca1\u6709\u6539\u53d8\u7684\u60c5\u51b5\u4e0b\uff0c\u5c06\u4e0d\u53d8\u7684\u5185\u5bb9\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0c\u76f4\u5230\u8fd9\u4e2a\u8fde\u63a5\u88ab\u5173\u95ed\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

>pipe\uff1a\u8868\u793a\u8fdb\u5165pipe\u6a21\u5f0f\uff0c\u8bf7\u628a\u8bf7\u6c42\u63a7\u5236\u6743\u4ea4\u7ed9vcl_pipe\u51fd\u6570\u3002\r\n>error code [reason]\uff1a\u8868\u793a\u8fd4\u56de\u201ccode\u201d\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u653e\u5f03\u5904\u7406\u8be5\u8bf7\u6c42\u3002<\/pre>\n
vcl_pass\u51fd\u6570<\/strong><\/span><\/div>\n

\u6b64\u51fd\u6570\u5728\u8fdb\u5165pass\u6a21\u5f0f\u65f6\u88ab\u8c03\u7528\uff0c\u7528\u4e8e\u5c06\u8bf7\u6c42\u76f4\u63a5\u4f20\u9012\u81f3\u540e\u7aef\u4e3b\u673a\u3002\u540e\u7aef\u4e3b\u673a\u5728\u5e94\u7b54\u6570\u636e\u540e\u5c06\u5e94\u7b54\u6570\u636e\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\uff0c\u4f46\u4e0d\u8fdb\u884c\u4efb\u4f55\u7f13\u5b58\uff0c\u5728\u5f53\u524d\u8fde\u63a5\u4e0b\u6bcf\u6b21\u90fd\u8fd4\u56de\u6700\u65b0\u7684\u5185\u5bb9\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

>pass\u3002\r\n>error code [reason]\uff1a\u8868\u793a\u8fd4\u56de\u201ccode\u201d\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u653e\u5f03\u5904\u7406\u8be5\u8bf7\u6c42\u3002<\/pre>\n
lookup<\/strong><\/span><\/div>\n

\u8868\u793a\u5728\u7f13\u5b58\u4e2d\u67e5\u627e\u88ab\u8bf7\u6c42\u7684\u5bf9\u8c61\uff0c\u5e76\u4e14\u6839\u636e\u67e5\u627e\u7684\u7ed3\u679c\u628a\u63a7\u5236\u6743\u4ea4\u7ed9vcl_hit\u6216\u8005\u51fd\u6570vcl_miss\u3002<\/p>\n

vcl_hit\u51fd\u6570<\/strong><\/span><\/div>\n

\u5728\u6267\u884clookup\u6307\u4ee4\u540e\uff0c\u5728\u7f13\u5b58\u4e2d\u627e\u5230\u8bf7\u6c42\u7684\u5185\u5bb9\u540e\u5c06\u81ea\u52a8\u8c03\u7528\u8be5\u51fd\u6570\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

>pass:\u8868\u793a\u8fdb\u5165pass\u6a21\u5f0f\uff0c\u628a\u8bf7\u6c42\u63a7\u5236\u6743\u4ea4\u7ed9vcl_pass\u51fd\u6570\u3002\r\n>deliver\uff1a\u8868\u793a\u5c06\u627e\u5230\u7684\u5185\u5bb9\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u628a\u63a7\u5236\u6743\u4ea4\u7ed9vcl_deliver\u3002\r\n>error code [reason]\uff1a\u8868\u793a\u8fd4\u56de\u201ccode\u201d\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u653e\u5f03\u5904\u7406\u8be5\u8bf7\u6c42\u3002<\/pre>\n
vcl_miss\u51fd\u6570<\/strong><\/span><\/div>\n

\u5728\u6267\u884clookup\u6307\u4ee4\u540e\uff0c\u5728\u7f13\u5b58\u4e2d\u6ca1\u6709\u627e\u5230\u8bf7\u6c42\u7684\u5185\u5bb9\u65f6\u81ea\u52a8\u8c03\u7528\u8be5\u65b9\u6cd5\u3002\u6b64\u51fd\u6570\u53ef\u7528\u4e8e\u5224\u65ad\u662f\u5426\u9700\u8981\u4ece\u540e\u7aef\u670d\u52a1\u5668\u83b7\u53d6\u5185\u5bb9\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

>pass\u3002\r\n>fetch\uff1a\u8868\u793a\u4ece\u540e\u7aef\u83b7\u53d6\u8bf7\u6c42\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u628a\u63a7\u5236\u6743\u4ea4\u7ed9vcl_fetch\u3002\r\n>error code [reason]\uff1a\u8868\u793a\u8fd4\u56de\u201ccode\u201d\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u653e\u5f03\u5904\u7406\u8be5\u8bf7\u6c42\u3002<\/pre>\n
vcl_fetch\u51fd\u6570<\/strong><\/span><\/div>\n

\u5728\u540e\u7aef\u4e3b\u673a\u66f4\u65b0\u7f13\u5b58\u5e76\u4e14\u83b7\u53d6\u5185\u5bb9\u540e\u8c03\u7528\u8be5\u65b9\u6cd5\uff0c\u63a5\u7740\uff0c\u901a\u8fc7\u5224\u65ad\u83b7\u53d6\u7684\u5185\u5bb9\u6765\u51b3\u5b9a\u662f\u5c06\u5185\u5bb9\u653e\u5165\u7f13\u5b58\uff0c\u8fd8\u662f\u76f4\u63a5\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

>pass\u3002\r\n>deliver\uff1a\u8868\u793a\u5c06\u627e\u5230\u7684\u5185\u5bb9\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u628a\u63a7\u5236\u6743\u4ea4\u7ed9vcl_deliver\u3002\r\n>error code [reason]\uff1a\u8868\u793a\u8fd4\u56de\u201ccode\u201d\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u653e\u5f03\u5904\u7406\u8be5\u8bf7\u6c42\u3002<\/pre>\n
vcl_deliver\u51fd\u6570<\/strong><\/span><\/div>\n

\u5c06\u5728\u7f13\u5b58\u4e2d\u627e\u5230\u8bf7\u6c42\u7684\u5185\u5bb9\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u524d\u8c03\u7528\u8be5\u65b9\u6cd5\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

 >deliver\uff1a\u8868\u793a\u5c06\u627e\u5230\u7684\u5185\u5bb9\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u628a\u63a7\u5236\u6743\u4ea4\u7ed9vcl_deliver\u3002\r\n>error code [reason]\uff1a\u8868\u793a\u8fd4\u56de\u201ccode\u201d\u7ed9\u5ba2\u6237\u7aef\uff0c\u5e76\u653e\u5f03\u5904\u7406\u8be5\u8bf7\u6c42\u3002<\/pre>\n
vcl_timeout\u51fd\u6570<\/strong><\/span><\/div>\n

\u5728\u7f13\u5b58\u5185\u5bb9\u5230\u671f\u524d\u8c03\u7528\u8be5\u51fd\u6570\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

\r\n>descard\uff1a\u8868\u793a\u4ece\u7f13\u5b58\u4e2d\u6e05\u695a\u8be5\u5185\u5bb9\u3002\r\n>fetch<\/pre>\n
vcl_discard\u51fd\u6570<\/strong><\/span><\/div>\n

\u5728\u7f13\u5b58\u5185\u5bb9\u5230\u671f\u540e\u6216\u7f13\u5b58\u7a7a\u95f4\u4e0d\u8db3\u65f6\uff0c\u81ea\u52a8\u8c03\u7528\u8be5\u51fd\u6570\u3002
\n\u6b64\u51fd\u6570\u4e00\u822c\u4ee5\u5982\u4e0b\u51e0\u4e2a\u5173\u952e\u5b57\u7ed3\u675f\uff1a<\/p>\n

>descard\r\n>keep\uff1a\u8868\u793a\u5c06\u5185\u5bb9\u7ee7\u7eed\u4fdd\u7559\u5728\u7f13\u5b58\u4e2d\u3002<\/pre>\n

\u672c\u6587\u539f\u521b\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/varnish-installation-configuration.html<\/a>\u4f5c\u8005\uff1a\u51af\u742a\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb Varnish\u662f\u4e00\u6b3e\u9ad8\u6027\u80fd\u4e14\u5f00\u6e90\u7684\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u548cHTTP\u52a0\u901f\u5668\uff0c\u5b83\u91c7\u7528\u4e86\u5168\u65b0\u7684\u8f6f\u4ef6\u4f53\u7cfb\u7ed3\u6784\uff0c\u548c\u73b0\u5728\u7684\u786c […]<\/p>\n","protected":false},"author":63,"featured_media":17488,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-17480","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/17480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=17480"}],"version-history":[{"count":7,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/17480\/revisions"}],"predecessor-version":[{"id":255210,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/17480\/revisions\/255210"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/17488"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=17480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=17480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=17480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}