{"id":2996,"date":"2014-03-02T06:28:05","date_gmt":"2014-03-02T06:28:05","guid":{"rendered":"http:\/\/blog.hmouse.tk\/?p=2996"},"modified":"2014-03-10T01:13:59","modified_gmt":"2014-03-09T17:13:59","slug":"varnish%e7%9b%b8%e5%85%b3","status":"publish","type":"post","link":"https:\/\/www.hmouse.cn\/?p=2996","title":{"rendered":"varnish\u76f8\u5173"},"content":{"rendered":"<p>varnish\u76f8\u5173<br \/>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/><\/p>\n<style type=\"text\/css\"><!--\nbody{\nmargin: 0 auto;\nfont-family: Georgia, Palatino, serif;\ncolor: #444444;\nline-height: 1;\nmax-width: 960px;\npadding: 5px;\n}\nh1, h2, h3, h4 {\ncolor: #111111;\nfont-weight: 400;\n}\nh1, h2, h3, h4, h5, p {\nmargin-bottom: 16px;\npadding: 0;\n}\nh1 {\nfont-size: 28px;\n}\nh2 {\nfont-size: 22px;\nmargin: 20px 0 6px;\n}\nh3 {\nfont-size: 21px;\n}\nh4 {\nfont-size: 18px;\n}\nh5 {\nfont-size: 16px;\n}\na {\ncolor: #0099ff;\nmargin: 0;\npadding: 0;\nvertical-align: baseline;\n}\na:hover {\ntext-decoration: none;\ncolor: #ff6600;\n}\na:visited {\ncolor: purple;\n}\nul, ol {\npadding: 0;\nmargin: 0;\n}\nli {\nline-height: 24px;\nmargin-left: 44px;\n}\nli ul, li ul {\nmargin-left: 24px;\n}\np, ul, ol {\nfont-size: 14px;\nline-height: 20px;\nmax-width: 540px;\n}\npre {\npadding: 0px 24px;\nmax-width: 800px;\nwhite-space: pre-wrap;\n}\ncode {\nfont-family: Consolas, Monaco, Andale Mono, monospace;\nline-height: 1.5;\nfont-size: 13px;\n}\naside {\ndisplay: block;\nfloat: right;\nwidth: 390px;\n}\nblockquote {\nborder-left:.5em solid #eee;\npadding: 0 2em;\nmargin-left:0;\nmax-width: 476px;\n}\nblockquote  cite {\nfont-size:14px;\nline-height:20px;\ncolor:#bfbfbf;\n}\n\n\nblockquote p {\ncolor: #666;\nmax-width: 460px;\n}\nhr {\nwidth: 540px;\ntext-align: left;\nmargin: 0 auto 0 0;\ncolor: #999;\n}\n\nbutton,\ninput,\nselect,\ntextarea {\nfont-size: 100%;\nmargin: 0;\nvertical-align: baseline;\n*vertical-align: middle;\n}\nbutton, input {\nline-height: normal;\n*overflow: visible;\n}\nbutton::-moz-focus-inner, input::-moz-focus-inner {\nborder: 0;\npadding: 0;\n}\nbutton,\ninput[type=\"button\"],\ninput[type=\"reset\"],\ninput[type=\"submit\"] {\ncursor: pointer;\n-webkit-appearance: button;\n}\ninput[type=checkbox], input[type=radio] {\ncursor: pointer;\n}\n\/* override default chrome & firefox settings *\/\ninput:not([type=\"image\"]), textarea {\n-webkit-box-sizing: content-box;\n-moz-box-sizing: content-box;\nbox-sizing: content-box;\n}\n\ninput[type=\"search\"] {\n-webkit-appearance: textfield;\n-webkit-box-sizing: content-box;\n-moz-box-sizing: content-box;\nbox-sizing: content-box;\n}\ninput[type=\"search\"]::-webkit-search-decoration {\n-webkit-appearance: none;\n}\nlabel,\ninput,\nselect,\ntextarea {\nfont-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\nfont-size: 13px;\nfont-weight: normal;\nline-height: normal;\nmargin-bottom: 18px;\n}\ninput[type=checkbox], input[type=radio] {\ncursor: pointer;\nmargin-bottom: 0;\n}\ninput[type=text],\ninput[type=password],\ntextarea,\nselect {\ndisplay: inline-block;\nwidth: 210px;\npadding: 4px;\nfont-size: 13px;\nfont-weight: normal;\nline-height: 18px;\nheight: 18px;\ncolor: #808080;\nborder: 1px solid #ccc;\n-webkit-border-radius: 3px;\n-moz-border-radius: 3px;\nborder-radius: 3px;\n}\nselect, input[type=file] {\nheight: 27px;\nline-height: 27px;\n}\ntextarea {\nheight: auto;\n}\n\n\/* grey out placeholders *\/\n:-moz-placeholder {\ncolor: #bfbfbf;\n}\n::-webkit-input-placeholder {\ncolor: #bfbfbf;\n}\n\ninput[type=text],\ninput[type=password],\nselect,\ntextarea {\n-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;\n-moz-transition: border linear 0.2s, box-shadow linear 0.2s;\ntransition: border linear 0.2s, box-shadow linear 0.2s;\n-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\nbox-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n}\ninput[type=text]:focus, input[type=password]:focus, textarea:focus {\noutline: none;\nborder-color: rgba(82, 168, 236, 0.8);\n-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\nbox-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n}\n\n\/* buttons *\/\nbutton {\ndisplay: inline-block;\npadding: 4px 14px;\nfont-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\nfont-size: 13px;\nline-height: 18px;\n-webkit-border-radius: 4px;\n-moz-border-radius: 4px;\nborder-radius: 4px;\n-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\n-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\nbox-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\nbackground-color: #0064cd;\nbackground-repeat: repeat-x;\nbackground-image: -khtml-gradient(linear, left top, left bottom, from(#049cdb), to(#0064cd));\nbackground-image: -moz-linear-gradient(top, #049cdb, #0064cd);\nbackground-image: -ms-linear-gradient(top, #049cdb, #0064cd);\nbackground-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd));\nbackground-image: -webkit-linear-gradient(top, #049cdb, #0064cd);\nbackground-image: -o-linear-gradient(top, #049cdb, #0064cd);\nbackground-image: linear-gradient(top, #049cdb, #0064cd);\ncolor: #fff;\ntext-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);\nborder: 1px solid #004b9a;\nborder-bottom-color: #003f81;\n-webkit-transition: 0.1s linear all;\n-moz-transition: 0.1s linear all;\ntransition: 0.1s linear all;\nborder-color: #0064cd #0064cd #003f81;\nborder-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);\n}\nbutton:hover {\ncolor: #fff;\nbackground-position: 0 -15px;\ntext-decoration: none;\n}\nbutton:active {\n-webkit-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n-moz-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\nbox-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n}\nbutton::-moz-focus-inner {\npadding: 0;\nborder: 0;\n}\n\n\/* CSS stylesheet is based on Kevin Burke's Markdown.css project (http:\/\/kevinburke.bitbucket.org\/markdowncss) *\/\n--><\/style>\n<p>&nbsp;<\/p>\n<p>\/usr\/local\/varnish3\/bin\/varnishncsa -F &#8220;%{X-Forwarded-For}i %h %l %u %t &#8220;%r&#8221; %s %b &#8220;%{Referer}i&#8221; &#8220;%{User-agent}i&#8221;&#8221; -n \/data\/varnish\/cache\/ -w \/data\/varnish\/log\/varnish.log<\/p>\n<p>X-Forwarded-For\u8bb0\u5f55\u6240\u6709IP\u8bbf\u95ee\u7684\u8bb0\u5f55\u3002\u53ef\u4ee5\u767e\u5ea6\u4e0b\u3002<\/p>\n<h6>#<\/h6>\n<p>varnish pass\u548cpipe\u7684\u533a\u522b\uff1a<\/p>\n<p>\u8fd9\u4e24\u5929\u5728\u5b66\u4e60varnish\uff0c\u5728\u5b66\u5230vcl\u65f6\uff0c\u4e0d\u7406\u89e3pipe\u548cpass\u7684\u533a\u522b\u4ee5\u53ca\u5982\u4f55\u533a\u5206\u52a0\u4ee5\u5e94\u7528\u3002\u901a\u8fc7\u4e24\u5929\u7684\u641c\u7d22\uff0c\u603b\u7b97\u662f\u7406\u6e05\u4e86\u6982\u5ff5\u3002\u73b0\u5728\u8bb0\u5f55\u5728\u535a\u5ba2\u4e0a\u8ddf\u5927\u5bb6\u5206\u4eab\u3002<\/p>\n<p>\u5f53 vcl_recv \u51fd\u6570\u63a5\u6536\u5230\u8bf7\u6c42\u65f6\uff0c\u5b83\u8981\u5224\u65ad\u5982\u4f55\u5904\u7406\u8fd9\u4e2a\u8bf7\u6c42\u3002\u6709\u4e09\u79cd\u60c5\u51b5 \uff1a<\/p>\n<p>01.\u8c03\u7528 pass \u51fd\u6570\uff0c\u4ece\u540e\u7aef\u670d\u52a1\u5668\u8c03\u7528\u6570\u636e\u3002<br \/>\n02.<br \/>\n03.\u8c03\u7528 pipe \u51fd\u6570\uff0c\u5efa\u7acb\u5ba2\u6237\u7aef\u548c\u540e\u7aef\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u76f4\u63a5\u8fde\u63a5\uff0c\u4ece\u540e\u7aef\u670d\u52a1\u5668\u8c03\u7528\u6570\u636e\u3002<br \/>\n04.<br \/>\n05.\u8c03\u7528lookup\u51fd\u6570\uff0c\u4ece\u7f13\u5b58\u4e2d\u67e5\u627e\u5e94\u7b54\u6570\u636e\u5e76\u8fd4\u56de\uff0c\u5982\u679c\u67e5\u627e\u4e0d\u5230\uff0c\u5219\u8c03\u7528pass\u51fd\u6570\u4ece\u540e\u7aef\u670d\u52a1\u5668<br \/>\n06.\u8c03\u7528\u6570\u636e \u3002<\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u6211\u5c31\u6709\u51e0\u4e2a\u7591\u60d1\uff1a<br \/>\n01.pass\u548cpipe\u90fd\u4ece\u540e\u7aef\u670d\u52a1\u5668\u53d6\u6570\u636e\uff0c\u5b83\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u4e0d\u540c\u5462\uff1f<br \/>\n02.<br \/>\n03.\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pass\uff0c\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pipe\u5462\uff1f<br \/>\n04.<br \/>\n05.\u4ec0\u4e48\u6837\u7684\u6570\u636e\u4f1a\u88ab\u7f13\u5b58\u5728varnish\u4e2d\u5462\uff1f<\/p>\n<p>\u5728\u7406\u89e3\u8fd9\u51e0\u4e2a\u95ee\u9898\u524d\uff0c\u9700\u8981\u5148\u7406\u89e3\u53e6\u5916\u4e00\u4e9b\u6982\u5ff5\uff1a<\/p>\n<p>01.http \u5efa\u7acb\u8fde\u63a5\u7684\u8fc7\u7a0b<\/p>\n<p>02.<br \/>\n03.http \u8bf7\u6c42\u7684\u7c7b\u578b:get post head<\/p>\n<p>\u5148\u8bf4http\u5efa\u7acb\u8fde\u63a5\u7684\u8fc7\u7a0b\uff08\u6211\u53ea\u5199\u4e0b\u5927\u6982\uff0c\u56e0\u4e3a\u4e0d\u662f\u672c\u6587\u7684\u91cd\u5fc3\uff0c\u5177\u4f53\u7684\u8bf7\u53e6\u5916\u4e0a\u7f51\u67e5\uff09\uff1a<\/p>\n<p>01.\u5f53\u6d4f\u89c8\u5668\u60f3\u8981\u83b7\u5f97\u4e00\u4e2a\u7f51\u9875\u5185\u5bb9\u65f6\uff0c\u5982\u5728\u6d4f\u89c8\u5668\u8f93\u5165www.google.com\u3002<br \/>\n02.<br \/>\n03.\u8fd9\u65f6\u6d4f\u89c8\u5668\u5f00\u59cb\u8ddf\u670d\u52a1\u5668\u5efa\u7acb\u8fde\u63a5\uff0c\u5148\u6267\u884c\u4e09\u6b21\u63e1\u624b\uff0c\u786e\u8ba4\u5efa\u7acb\u8fde\u63a5\u3002<br \/>\n04.<br \/>\n05.\u4e4b\u540e\u6d4f\u89c8\u5668\u4f1a\u53d1\u9001\u8bf7\u6c42\uff0c\u4e00\u4e2a\u7f51\u9875\u5305\u542b\u591a\u4e2a\u5185\u5bb9\uff0c\u5982\u56fe\u7247\uff0c\u6b63\u6587\uff0chtml\u4ee3\u7801\uff0ccss\u4ee3\u7801,js\u4ee3\u7801\u3002<br \/>\n06.\u5982\u679c\u5728html 1.0\u7248\u672c\u4e2d\uff0c\u8bf7\u6c42\u4e00\u4e2a\u6587\u4ef6\u662f\u9700\u8981\u5efa\u7acb\u4e00\u6b21\u8fde\u63a5\u7684\uff0c\u591a\u4e2a\u8bf7\u6c42\u591a\u4e2a\u8fde\u63a5\u3002\u5f00\u9500\u662f\u5f88\u5927\u7684\u3002<br \/>\n07.\u800c\u5728HTML 1.1\u4e2d\uff0c\u5177\u6709\u4e86\u957f\u8fde\u63a5\u7684\u7279\u6027\uff0c\u5141\u8bb8\u5728keep-live \u65f6\u95f4\u5185\u4fdd\u6301\u8fde\u63a5\uff0c\u5728\u8fd9\u6bb5\u65f6\u95f4\u5185\u65e0\u987b<br \/>\n08.\u518d\u5efa\u7acb\u8fde\u63a5\u5c31\u53ef\u4ee5\u53d1\u9001\u591a\u4e2a\u8bf7\u6c42\u3002<br \/>\n09.<br \/>\n10.\u8bf7\u6c42\u5b8c\u6210 \u6216 keep-live\u65f6\u95f4\u5230\u9650\uff0c\u8fde\u63a5\u65ad\u5f00\u3002<\/p>\n<p>HTTP \u8bf7\u6c42\u7684\u7c7b\u578b\uff1a<\/p>\n<p>01.HTTP \u8bf7\u6c42\u7684\u7c7b\u578b\u6709\u51e0\u79cd\uff0c\u4e0b\u9762\u662f\u4e3b\u8981\u7684\u51e0\u79cd\uff1a<br \/>\n02. GET \uff1a \u8bf7\u6c42\u6307\u5b9a\u7684\u9875\u9762\u4fe1\u606f\uff0c\u5e76\u8fd4\u56de\u5b9e\u4f53\u4e3b\u4f53\u3002<br \/>\n03.\u3000HEAD\uff1a \u53ea\u8bf7\u6c42\u9875\u9762\u7684\u9996\u90e8\u3002<br \/>\n04.\u3000POST\uff1a \u8bf7\u6c42\u670d\u52a1\u5668\u63a5\u53d7\u6240\u6307\u5b9a\u7684\u6587\u6863\u4f5c\u4e3a\u5bf9\u6240\u6807\u8bc6\u7684URI\u7684\u65b0\u7684\u4ece\u5c5e\u5b9e\u4f53\u3002<\/p>\n<p>\u8bf4\u767d\u4e86\uff0c\u8bf7\u6c42\u4e00\u4e2a\u9759\u6001\u7684HTML\u9875\u9762\u5c31\u662f\u7528get\u7c7b\u578b\uff0c\u800c\u5982\u679c\u4f60\u5728\u65b0\u6d6a\u5fae\u535a\u4e0a\u53d1\u4e00\u6761\u5fae\u535a\uff0c\u5176\u5b9e\u5c31\u662fpost \u7c7b\u578b\u3002<\/p>\n<p>\u603b\u7ed3\u6765\u8bf4\uff0cget\u662f\u8bf7\u6c42\u76f8\u5173URI\u5e76\u63a5\u53d7\u670d\u52a1\u5668\u7684\u8fd4\u56de\u6570\u636e\u3002\u4e3a\u4e86\u63a5\u6536\u6570\u636e\u3002<\/p>\n<p>post\u662f\u53d1\u9001\u6570\u636e\u7ed9\u670d\u52a1\u5668\uff0c\u670d\u52a1\u5668\u9700\u8981\u5bf9\u8fd9\u4e9b\u6570\u636e\u505a\u76f8\u5e94\u7684\u5904\u7406\u3002\u4e3a\u4e86\u53d1\u9001\u6570\u636e\u3002<\/p>\n<p>\u4ee5\u4e0a\u90fd\u660e\u767d\u7684\u8bdd\uff0c\u5c31\u53ef\u4ee5\u89e3\u7b54\u8fd9\u4e09\u4e2a\u95ee\u9898\u4e86\uff1a<\/p>\n<p>01.pass\u548cpipe\u90fd\u4ece\u540e\u7aef\u670d\u52a1\u5668\u53d6\u6570\u636e\uff0c\u5b83\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u4e0d\u540c\u5462\uff1f<\/p>\n<p>02.<\/p>\n<p>03.\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pass\uff0c\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pipe\u5462\uff1f<\/p>\n<p>04.<\/p>\n<p>05.\u4ec0\u4e48\u6837\u7684\u6570\u636e\u4f1a\u88ab\u7f13\u5b58\u5728varnish\u4e2d\u5462\uff1f<\/p>\n<p>01.\u95ee\uff1apass\u548cpipe\u90fd\u4ece\u540e\u7aef\u670d\u52a1\u5668\u53d6\u6570\u636e\uff0c\u5b83\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u4e0d\u540c\u5462\uff1f<\/p>\n<p>02.\u7b54\uff1a\u5f53vcl<em>recv\u8c03\u7528 pass \u51fd\u6570\u65f6\uff0cpass\u5c06\u5f53\u524d\u8bf7\u6c42\u76f4\u63a5\u8f6c\u53d1\u5230\u540e\u7aef\u670d\u52a1\u5668\u3002\u800c\u540e\u7eed\u7684\u8bf7\u6c42\u4ecd\u7136<br \/>\n03.\u901a\u8fc7varnish\u5904\u7406\u3002<br \/>\n04.\u4f8b\u5982\uff0c\u5efa\u7acb\u4e86HTTP\u8fde\u63a5\u4e4b\u540e\uff0c\u5ba2\u6237\u7aef\u987a\u5e8f\u8bf7\u6c42 a.css \u3001a.png\u4e24\u4e2a\u6587\u4ef6\uff0c\u201c\u5f53\u524d\u8bf7\u6c42\u201d\u6307\u7684\u662f\u7b2c\u4e00\u4e2a<br \/>\n05.\u8bf7\u6c42\uff0c\u5373a.css\uff0ca.css\u88ab\u76f4\u63a5\u8f6c\u53d1\u5230\u540e\u7aef\u670d\u52a1\u5668\uff0c\u4e0d\u88ab\u7f13\u5b58\u3002\u800c\u540e\u7eed\u7684a.png\u5219\u518d\u7531varnish\u6765\u505a<br \/>\n06.\u5904\u7406\uff0cvarnish\u4f1a\u5224\u65ada.png \u5982\u4f55\u5904\u7406\u3002<br \/>\n07.\u603b\u7ed3\uff1a\u4e00\u4e2a\u8fde\u63a5\u4e2d\u9664\u4e86\u5f53\u524d\u8bf7\u6c42\uff0c\u5176\u5b83\u8bf7\u6c42\u4ecd\u7136\u6309\u7167\u6b63\u5e38\u60c5\u51b5\u7531varnish\u5904\u7406\u3002<br \/>\n08.<br \/>\n09.\u800cpipe\u6a21\u5f0f\u5219\u4e0d\u4e00\u6837\uff0c\u5f53vcl<\/em>recv\u5224\u65ad \u9700\u8981\u8c03\u7528 pipe \u51fd\u6570\u65f6\uff0cvarnish\u4f1a\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b<br \/>\n10.\u95f4\u5efa\u7acb\u4e00\u6761\u76f4\u63a5\u7684\u8fde\u63a5 \uff0c\u4e4b\u540e\u5ba2\u6237\u7aef\u7684\u6240\u6709\u8bf7\u6c42\u90fd\u76f4\u63a5\u53d1\u9001\u7ed9\u670d\u52a1\u5668\uff0c\u7ed5\u8fc7varnish,\u4e0d\u518d\u7531varnish<br \/>\n11.\u68c0\u67e5\u8bf7\u6c42\uff0c\u76f4\u5230\u8fde\u63a5\u65ad\u5f00\u3002<\/p>\n<p>01.\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pass\uff0c\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pipe\u5462\uff1f<\/p>\n<p>02.\u7b54\uff1apass \u901a\u5e38\u53ea\u5904\u7406\u9759\u6001\u9875\u9762\u3002\u5373\u53ea\u5728GET \u548c HEAD \u7c7b\u578b\u7684\u8bf7\u6c42\u4e2d\u65f6\u624d\u9002\u5408\u8c03\u7528pass\u51fd\u6570\u3002<br \/>\n03.\u53e6\u5916\uff0c\u9700\u8981\u6ce8\u610f\u7684\u4e00\u70b9\u662f\uff0cpass\u6a21\u5f0f\u4e0d\u80fd\u5904\u7406POST\u8bf7\u6c42\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f\u56e0\u4e3aPOST\u8bf7\u6c42\u4e00\u822c\u662f\u53d1\u9001<br \/>\n04.\u6570\u636e\u7ed9\u670d\u52a1\u5668\uff0c\u9700\u8981\u670d\u52a1\u5668\u63a5\u6536\u6570\u636e\uff0c\u5e76\u5904\u7406\u6570\u636e\uff0c\u53cd\u9988\u6570\u636e \u3002\u662f\u52a8\u6001\u7684\uff0c\u4e0d\u4f5c\u7f13\u5b58\u3002<br \/>\n05.\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b:<br \/>\n06.if (req.request !=&#8221;GET&#8221; &amp;&amp; req.request != &#8220;HEAD&#8221;)<br \/>\n07.{<\/p>\n<p>08.return (pipe);<\/p>\n<p>09.}<\/p>\n<p>10.\u90a3\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pipe?\u7531\u4ee5\u4e0a\u9648\u8ff0\u53ef\u4ee5\u77e5\uff0c\u7c7b\u578b\u662fPOST\u65f6\u7528pipe\uff0c\u4f46\u662f\u4e5f\u8bb8\u8fd8\u4e0d\u592a\u6e05\u6670\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c<br \/>\n11.\u5f53\u5ba2\u6237\u7aef\u5728\u8bf7\u6c42\u4e00\u4e2a\u89c6\u9891\u6587\u4ef6\u65f6\uff0c\u6216\u8005\u4e00\u4e2a\u5927\u7684\u6587\u6863\uff0c\u5982.zip .tar \u6587\u4ef6\uff0c\u5c31\u9700\u8981\u7528pipe\u6a21\u5f0f\uff0c<br \/>\n12.\u8fd9\u4e9b\u5927\u7684\u6587\u4ef6\u662f\u4e0d\u88ab\u7f13\u5b58\u5728varnish\u4e2d\u7684\u3002<\/p>\n<p>01.\u4ec0\u4e48\u6837\u7684\u6570\u636e\u4f1a\u88ab\u7f13\u5b58\u5728varnish\u4e2d\u5462\uff1f<\/p>\n<p>02.\u7b54:varnish\u53ea\u7f13\u5b58\u9759\u6001\u6570\u636e\u3002\u5728\u7f51\u4e0a\u641c\u5230\u7684varnish\u7f13\u5b58\u7b56\u7565\uff0c\u53ef\u4ee5\u89e3\u7b54\u8fd9\u4e2a\u95ee\u9898\uff1a<br \/>\n03.varnish\u7f13\u5b58\u7b56\u7565<br \/>\n04.<br \/>\n05.\u7f3a\u7701\u662f\u6839\u6910\u540e\u7aef\u8fd4\u56de\u7684http\u72b6\u6001\u7801\u51b3\u5b9a\u662f\u5426\u7f13\u5b58\u3002\u53ef\u4ee5\u7f13\u5b58\u7684\u72b6\u6001\u7801\u5982\u4e0b\uff1a<br \/>\n06.200<\/p>\n<p>07.203<\/p>\n<p>08.300<\/p>\n<p>09.301<\/p>\n<p>10.302<\/p>\n<p>11.410<\/p>\n<p>12.404<\/p>\n<p>13.<br \/>\n14.varnish\u73b0\u5728\u8fd8\u4e0d\u652f\u6301ranges\u8bf7\u6c42\uff0c\u6240\u4ee5\u4e0d\u4f1a\u7f13\u5b58206\u72b6\u6001\u7684\u7ed3\u679c\u3002<br \/>\n15.<br \/>\n16.\u7ba1\u7406\u5458\u53ef\u4ee5\u5728vcl\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684vcl<em>fetch\u90e8\u5206\uff0c\u52a0\u5165\u81ea\u5df2\u7684\u7f13\u5b58\u7b56\u7565\uff0c\u65b9\u6cd5\u662f\u4fee\u6539beresp.cacheable\u53d8\u91cf\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\uff0c\u770b\u540e\u7aef\u8fd4\u56de\u4e2d\u5982\u679c\u8bbe\u7f6e\u4e86cookie\uff0c\u5219\u4e0d\u7f13\u5b58\uff1a<br \/>\n17.<br \/>\n18.sub fetch {<br \/>\n19.<br \/>\n20. if (beresp.http.Set-Cookie) {<br \/>\n21. set beresp.cacheable = false;<br \/>\n22. }<br \/>\n23.}<br \/>\n24.\u53c2\u8003\u6587\u7ae0\uff1ahttp:\/\/blog.sina.com.cn\/s\/blog<\/em>5374d6e30100tupo.html<\/p>\n<p>\u6587\u7ae0\u672b\u5c3e\u603b\u7ed3\uff1a\u5b66\u6280\u672f\u4e0d\u8981\u6b7b\u6263\u4e2d\u6587\u6587\u6863\uff0c\u591a\u770b\u82f1\u6587\u6587\u6863\u4f1a\u6bd4\u8f83\u6709\u5e2e\u52a9 \u3002<\/p>\n<p><!-- This document was created with MarkdownPad, the Markdown editor for Windows (http:\/\/markdownpad.com) --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>varnish\u76f8\u5173<br \/>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/><\/p>\n<style type=\"text\/css\"><!--\nbody{\nmargin: 0 auto;\nfont-family: Georgia, Palatino, serif;\ncolor: #444444;\nline-height: 1;\nmax-width: 960px;\npadding: 5px;\n}\nh1, h2, h3, h4 {\ncolor: #111111;\nfont-weight: 400;\n}\nh1, h2, h3, h4, h5, p {\nmargin-bottom: 16px;\npadding: 0;\n}\nh1 {\nfont-size: 28px;\n}\nh2 {\nfont-size: 22px;\nmargin: 20px 0 6px;\n}\nh3 {\nfont-size: 21px;\n}\nh4 {\nfont-size: 18px;\n}\nh5 {\nfont-size: 16px;\n}\na {\ncolor: #0099ff;\nmargin: 0;\npadding: 0;\nvertical-align: baseline;\n}\na:hover {\ntext-decoration: none;\ncolor: #ff6600;\n}\na:visited {\ncolor: purple;\n}\nul, ol {\npadding: 0;\nmargin: 0;\n}\nli {\nline-height: 24px;\nmargin-left: 44px;\n}\nli ul, li ul {\nmargin-left: 24px;\n}\np, ul, ol {\nfont-size: 14px;\nline-height: 20px;\nmax-width: 540px;\n}\npre {\npadding: 0px 24px;\nmax-width: 800px;\nwhite-space: pre-wrap;\n}\ncode {\nfont-family: Consolas, Monaco, Andale Mono, monospace;\nline-height: 1.5;\nfont-size: 13px;\n}\naside {\ndisplay: block;\nfloat: right;\nwidth: 390px;\n}\nblockquote {\nborder-left:.5em solid #eee;\npadding: 0 2em;\nmargin-left:0;\nmax-width: 476px;\n}\nblockquote  cite {\nfont-size:14px;\nline-height:20px;\ncolor:#bfbfbf;\n}\n\n\nblockquote p {\ncolor: #666;\nmax-width: 460px;\n}\nhr {\nwidth: 540px;\ntext-align: left;\nmargin: 0 auto 0 0;\ncolor: #999;\n}\n\nbutton,\ninput,\nselect,\ntextarea {\nfont-size: 100%;\nmargin: 0;\nvertical-align: baseline;\n*vertical-align: middle;\n}\nbutton, input {\nline-height: normal;\n*overflow: visible;\n}\nbutton::-moz-focus-inner, input::-moz-focus-inner {\nborder: 0;\npadding: 0;\n}\nbutton,\ninput[type=\"button\"],\ninput[type=\"reset\"],\ninput[type=\"submit\"] {\ncursor: pointer;\n-webkit-appearance: button;\n}\ninput[type=checkbox], input[type=radio] {\ncursor: pointer;\n}\n\/* override default chrome &#038; firefox settings *\/\ninput:not([type=\"image\"]), textarea {\n-webkit-box-sizing: content-box;\n-moz-box-sizing: content-box;\nbox-sizing: content-box;\n}\n\ninput[type=\"search\"] {\n-webkit-appearance: textfield;\n-webkit-box-sizing: content-box;\n-moz-box-sizing: content-box;\nbox-sizing: content-box;\n}\ninput[type=\"search\"]::-webkit-search-decoration {\n-webkit-appearance: none;\n}\nlabel,\ninput,\nselect,\ntextarea {\nfont-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\nfont-size: 13px;\nfont-weight: normal;\nline-height: normal;\nmargin-bottom: 18px;\n}\ninput[type=checkbox], input[type=radio] {\ncursor: pointer;\nmargin-bottom: 0;\n}\ninput[type=text],\ninput[type=password],\ntextarea,\nselect {\ndisplay: inline-block;\nwidth: 210px;\npadding: 4px;\nfont-size: 13px;\nfont-weight: normal;\nline-height: 18px;\nheight: 18px;\ncolor: #808080;\nborder: 1px solid #ccc;\n-webkit-border-radius: 3px;\n-moz-border-radius: 3px;\nborder-radius: 3px;\n}\nselect, input[type=file] {\nheight: 27px;\nline-height: 27px;\n}\ntextarea {\nheight: auto;\n}\n\n\/* grey out placeholders *\/\n:-moz-placeholder {\ncolor: #bfbfbf;\n}\n::-webkit-input-placeholder {\ncolor: #bfbfbf;\n}\n\ninput[type=text],\ninput[type=password],\nselect,\ntextarea {\n-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;\n-moz-transition: border linear 0.2s, box-shadow linear 0.2s;\ntransition: border linear 0.2s, box-shadow linear 0.2s;\n-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\nbox-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n}\ninput[type=text]:focus, input[type=password]:focus, textarea:focus {\noutline: none;\nborder-color: rgba(82, 168, 236, 0.8);\n-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\nbox-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n}\n\n\/* buttons *\/\nbutton {\ndisplay: inline-block;\npadding: 4px 14px;\nfont-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\nfont-size: 13px;\nline-height: 18px;\n-webkit-border-radius: 4px;\n-moz-border-radius: 4px;\nborder-radius: 4px;\n-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\n-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\nbox-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\nbackground-color: #0064cd;\nbackground-repeat: repeat-x;\nbackground-image: -khtml-gradient(linear, left top, left bottom, from(#049cdb), to(#0064cd));\nbackground-image: -moz-linear-gradient(top, #049cdb, #0064cd);\nbackground-image: -ms-linear-gradient(top, #049cdb, #0064cd);\nbackground-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd));\nbackground-image: -webkit-linear-gradient(top, #049cdb, #0064cd);\nbackground-image: -o-linear-gradient(top, #049cdb, #0064cd);\nbackground-image: linear-gradient(top, #049cdb, #0064cd);\ncolor: #fff;\ntext-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);\nborder: 1px solid #004b9a;\nborder-bottom-color: #003f81;\n-webkit-transition: 0.1s linear all;\n-moz-transition: 0.1s linear all;\ntransition: 0.1s linear all;\nborder-color: #0064cd #0064cd #003f81;\nborder-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);\n}\nbutton:hover {\ncolor: #fff;\nbackground-position: 0 -15px;\ntext-decoration: none;\n}\nbutton:active {\n-webkit-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n-moz-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\nbox-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n}\nbutton::-moz-focus-inner {\npadding: 0;\nborder: 0;\n}\n\n\/* CSS stylesheet is based on Kevin Burke's Markdown.css project (http:\/\/kevinburke.bitbucket.org\/markdowncss) *\/\n--><\/style>\n<p>&nbsp;<\/p>\n<p>\/usr\/local\/varnish3\/bin\/varnishncsa -F &#8220;%{X-Forwarded-For}i %h %l %u %t &#8220;%r&#8221; %s %b &#8220;%{Referer}i&#8221; &#8220;%{User-agent}i&#8221;&#8221; -n \/data\/varnish\/cache\/ -w \/data\/varnish\/log\/varnish.log<\/p>\n<p>X-Forwarded-For\u8bb0\u5f55\u6240\u6709IP\u8bbf\u95ee\u7684\u8bb0\u5f55\u3002\u53ef\u4ee5\u767e\u5ea6\u4e0b\u3002<\/p>\n<h6>#<\/h6>\n<p>varnish pass\u548cpipe\u7684\u533a\u522b\uff1a<\/p>\n<p>\u8fd9\u4e24\u5929\u5728\u5b66\u4e60varnish\uff0c\u5728\u5b66\u5230vcl\u65f6\uff0c\u4e0d\u7406\u89e3pipe\u548cpass\u7684\u533a\u522b\u4ee5\u53ca\u5982\u4f55\u533a\u5206\u52a0\u4ee5\u5e94\u7528\u3002\u901a\u8fc7\u4e24\u5929\u7684\u641c\u7d22\uff0c\u603b\u7b97\u662f\u7406\u6e05\u4e86\u6982\u5ff5\u3002\u73b0\u5728\u8bb0\u5f55\u5728\u535a\u5ba2\u4e0a\u8ddf\u5927\u5bb6\u5206\u4eab\u3002<\/p>\n<p>\u5f53 vcl_recv \u51fd\u6570\u63a5\u6536\u5230\u8bf7\u6c42\u65f6\uff0c\u5b83\u8981\u5224\u65ad\u5982\u4f55\u5904\u7406\u8fd9\u4e2a\u8bf7\u6c42\u3002\u6709\u4e09\u79cd\u60c5\u51b5 \uff1a<\/p>\n<p>01.\u8c03\u7528 pass \u51fd\u6570\uff0c\u4ece\u540e\u7aef\u670d\u52a1\u5668\u8c03\u7528\u6570\u636e\u3002<br \/>\n02.<br \/>\n03.\u8c03\u7528 pipe \u51fd\u6570\uff0c\u5efa\u7acb\u5ba2\u6237\u7aef\u548c\u540e\u7aef\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u76f4\u63a5\u8fde\u63a5\uff0c\u4ece\u540e\u7aef\u670d\u52a1\u5668\u8c03\u7528\u6570\u636e\u3002<br \/>\n04.<br \/>\n05.\u8c03\u7528lookup\u51fd\u6570\uff0c\u4ece\u7f13\u5b58\u4e2d\u67e5\u627e\u5e94\u7b54\u6570\u636e\u5e76\u8fd4\u56de\uff0c\u5982\u679c\u67e5\u627e\u4e0d\u5230\uff0c\u5219\u8c03\u7528pass\u51fd\u6570\u4ece\u540e\u7aef\u670d\u52a1\u5668<br \/>\n06.\u8c03\u7528\u6570\u636e \u3002<\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u6211\u5c31\u6709\u51e0\u4e2a\u7591\u60d1\uff1a<br \/>\n01.pass\u548cpipe\u90fd\u4ece\u540e\u7aef\u670d\u52a1\u5668\u53d6\u6570\u636e\uff0c\u5b83\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u4e0d\u540c\u5462\uff1f<br \/>\n02.<br \/>\n03.\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pass\uff0c\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pipe\u5462\uff1f<br \/>\n04.<br \/>\n05.\u4ec0\u4e48\u6837\u7684\u6570\u636e\u4f1a\u88ab\u7f13\u5b58\u5728varnish\u4e2d\u5462\uff1f<\/p>\n<p>\u5728\u7406\u89e3\u8fd9\u51e0\u4e2a\u95ee\u9898\u524d\uff0c\u9700\u8981\u5148\u7406\u89e3\u53e6\u5916\u4e00\u4e9b\u6982\u5ff5\uff1a<\/p>\n<p>01.http \u5efa\u7acb\u8fde\u63a5\u7684\u8fc7\u7a0b<\/p>\n<p>02.<br \/>\n03.http \u8bf7\u6c42\u7684\u7c7b\u578b:get post head<\/p>\n<p>\u5148\u8bf4http\u5efa\u7acb\u8fde\u63a5\u7684\u8fc7\u7a0b\uff08\u6211\u53ea\u5199\u4e0b\u5927\u6982\uff0c\u56e0\u4e3a\u4e0d\u662f\u672c\u6587\u7684\u91cd\u5fc3\uff0c\u5177\u4f53\u7684\u8bf7\u53e6\u5916\u4e0a\u7f51\u67e5\uff09\uff1a<\/p>\n<p>01.\u5f53\u6d4f\u89c8\u5668\u60f3\u8981\u83b7\u5f97\u4e00\u4e2a\u7f51\u9875\u5185\u5bb9\u65f6\uff0c\u5982\u5728\u6d4f\u89c8\u5668\u8f93\u5165www.google.com\u3002<br \/>\n02.<br \/>\n03.\u8fd9\u65f6\u6d4f\u89c8\u5668\u5f00\u59cb\u8ddf\u670d\u52a1\u5668\u5efa\u7acb\u8fde\u63a5\uff0c\u5148\u6267\u884c\u4e09\u6b21\u63e1\u624b\uff0c\u786e\u8ba4\u5efa\u7acb\u8fde\u63a5\u3002<br \/>\n04.<br \/>\n05.\u4e4b\u540e\u6d4f\u89c8\u5668\u4f1a\u53d1\u9001\u8bf7\u6c42\uff0c\u4e00\u4e2a\u7f51\u9875\u5305\u542b\u591a\u4e2a\u5185\u5bb9\uff0c\u5982\u56fe\u7247\uff0c\u6b63\u6587\uff0chtml\u4ee3\u7801\uff0ccss\u4ee3\u7801,js\u4ee3\u7801\u3002<br \/>\n06.\u5982\u679c\u5728html 1.0\u7248\u672c\u4e2d\uff0c\u8bf7\u6c42\u4e00\u4e2a\u6587\u4ef6\u662f\u9700\u8981\u5efa\u7acb\u4e00\u6b21\u8fde\u63a5\u7684\uff0c\u591a\u4e2a\u8bf7\u6c42\u591a\u4e2a\u8fde\u63a5\u3002\u5f00\u9500\u662f\u5f88\u5927\u7684\u3002<br \/>\n07.\u800c\u5728HTML 1.1\u4e2d\uff0c\u5177\u6709\u4e86\u957f\u8fde\u63a5\u7684\u7279\u6027\uff0c\u5141\u8bb8\u5728keep-live \u65f6\u95f4\u5185\u4fdd\u6301\u8fde\u63a5\uff0c\u5728\u8fd9\u6bb5\u65f6\u95f4\u5185\u65e0\u987b<br \/>\n08.\u518d\u5efa\u7acb\u8fde\u63a5\u5c31\u53ef\u4ee5\u53d1\u9001\u591a\u4e2a\u8bf7\u6c42\u3002<br \/>\n09.<br \/>\n10.\u8bf7\u6c42\u5b8c\u6210 \u6216 keep-live\u65f6\u95f4\u5230\u9650\uff0c\u8fde\u63a5\u65ad\u5f00\u3002<\/p>\n<p>HTTP \u8bf7\u6c42\u7684\u7c7b\u578b\uff1a<\/p>\n<p>01.HTTP \u8bf7\u6c42\u7684\u7c7b\u578b\u6709\u51e0\u79cd\uff0c\u4e0b\u9762\u662f\u4e3b\u8981\u7684\u51e0\u79cd\uff1a<br \/>\n02. GET \uff1a \u8bf7\u6c42\u6307\u5b9a\u7684\u9875\u9762\u4fe1\u606f\uff0c\u5e76\u8fd4\u56de\u5b9e\u4f53\u4e3b\u4f53\u3002<br \/>\n03.\u3000HEAD\uff1a \u53ea\u8bf7\u6c42\u9875\u9762\u7684\u9996\u90e8\u3002<br \/>\n04.\u3000POST\uff1a \u8bf7\u6c42\u670d\u52a1\u5668\u63a5\u53d7\u6240\u6307\u5b9a\u7684\u6587\u6863\u4f5c\u4e3a\u5bf9\u6240\u6807\u8bc6\u7684URI\u7684\u65b0\u7684\u4ece\u5c5e\u5b9e\u4f53\u3002<\/p>\n<p>\u8bf4\u767d\u4e86\uff0c\u8bf7\u6c42\u4e00\u4e2a\u9759\u6001\u7684HTML\u9875\u9762\u5c31\u662f\u7528get\u7c7b\u578b\uff0c\u800c\u5982\u679c\u4f60\u5728\u65b0\u6d6a\u5fae\u535a\u4e0a\u53d1\u4e00\u6761\u5fae\u535a\uff0c\u5176\u5b9e\u5c31\u662fpost \u7c7b\u578b\u3002<\/p>\n<p>\u603b\u7ed3\u6765\u8bf4\uff0cget\u662f\u8bf7\u6c42\u76f8\u5173URI\u5e76\u63a5\u53d7\u670d\u52a1\u5668\u7684\u8fd4\u56de\u6570\u636e\u3002\u4e3a\u4e86\u63a5\u6536\u6570\u636e\u3002<\/p>\n<p>post\u662f\u53d1\u9001\u6570\u636e\u7ed9\u670d\u52a1\u5668\uff0c\u670d\u52a1\u5668\u9700\u8981\u5bf9\u8fd9\u4e9b\u6570\u636e\u505a\u76f8\u5e94\u7684\u5904\u7406\u3002\u4e3a\u4e86\u53d1\u9001\u6570\u636e\u3002<\/p>\n<p>\u4ee5\u4e0a\u90fd\u660e\u767d\u7684\u8bdd\uff0c\u5c31\u53ef\u4ee5\u89e3\u7b54\u8fd9\u4e09\u4e2a\u95ee\u9898\u4e86\uff1a<\/p>\n<p>01.pass\u548cpipe\u90fd\u4ece\u540e\u7aef\u670d\u52a1\u5668\u53d6\u6570\u636e\uff0c\u5b83\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u4e0d\u540c\u5462\uff1f<\/p>\n<p>02.<\/p>\n<p>03.\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pass\uff0c\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pipe\u5462\uff1f<\/p>\n<p>04.<\/p>\n<p>05.\u4ec0\u4e48\u6837\u7684\u6570\u636e\u4f1a\u88ab\u7f13\u5b58\u5728varnish\u4e2d\u5462\uff1f<\/p>\n<p>01.\u95ee\uff1apass\u548cpipe\u90fd\u4ece\u540e\u7aef\u670d\u52a1\u5668\u53d6\u6570\u636e\uff0c\u5b83\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u4e0d\u540c\u5462\uff1f<\/p>\n<p>02.\u7b54\uff1a\u5f53vcl<em>recv\u8c03\u7528 pass \u51fd\u6570\u65f6\uff0cpass\u5c06\u5f53\u524d\u8bf7\u6c42\u76f4\u63a5\u8f6c\u53d1\u5230\u540e\u7aef\u670d\u52a1\u5668\u3002\u800c\u540e\u7eed\u7684\u8bf7\u6c42\u4ecd\u7136<br \/>\n03.\u901a\u8fc7varnish\u5904\u7406\u3002<br \/>\n04.\u4f8b\u5982\uff0c\u5efa\u7acb\u4e86HTTP\u8fde\u63a5\u4e4b\u540e\uff0c\u5ba2\u6237\u7aef\u987a\u5e8f\u8bf7\u6c42 a.css \u3001a.png\u4e24\u4e2a\u6587\u4ef6\uff0c\u201c\u5f53\u524d\u8bf7\u6c42\u201d\u6307\u7684\u662f\u7b2c\u4e00\u4e2a<br \/>\n05.\u8bf7\u6c42\uff0c\u5373a.css\uff0ca.css\u88ab\u76f4\u63a5\u8f6c\u53d1\u5230\u540e\u7aef\u670d\u52a1\u5668\uff0c\u4e0d\u88ab\u7f13\u5b58\u3002\u800c\u540e\u7eed\u7684a.png\u5219\u518d\u7531varnish\u6765\u505a<br \/>\n06.\u5904\u7406\uff0cvarnish\u4f1a\u5224\u65ada.png \u5982\u4f55\u5904\u7406\u3002<br \/>\n07.\u603b\u7ed3\uff1a\u4e00\u4e2a\u8fde\u63a5\u4e2d\u9664\u4e86\u5f53\u524d\u8bf7\u6c42\uff0c\u5176\u5b83\u8bf7\u6c42\u4ecd\u7136\u6309\u7167\u6b63\u5e38\u60c5\u51b5\u7531varnish\u5904\u7406\u3002<br \/>\n08.<br \/>\n09.\u800cpipe\u6a21\u5f0f\u5219\u4e0d\u4e00\u6837\uff0c\u5f53vcl<\/em>recv\u5224\u65ad \u9700\u8981\u8c03\u7528 pipe \u51fd\u6570\u65f6\uff0cvarnish\u4f1a\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b<br \/>\n10.\u95f4\u5efa\u7acb\u4e00\u6761\u76f4\u63a5\u7684\u8fde\u63a5 \uff0c\u4e4b\u540e\u5ba2\u6237\u7aef\u7684\u6240\u6709\u8bf7\u6c42\u90fd\u76f4\u63a5\u53d1\u9001\u7ed9\u670d\u52a1\u5668\uff0c\u7ed5\u8fc7varnish,\u4e0d\u518d\u7531varnish<br \/>\n11.\u68c0\u67e5\u8bf7\u6c42\uff0c\u76f4\u5230\u8fde\u63a5\u65ad\u5f00\u3002<\/p>\n<p>01.\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pass\uff0c\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pipe\u5462\uff1f<\/p>\n<p>02.\u7b54\uff1apass \u901a\u5e38\u53ea\u5904\u7406\u9759\u6001\u9875\u9762\u3002\u5373\u53ea\u5728GET \u548c HEAD \u7c7b\u578b\u7684\u8bf7\u6c42\u4e2d\u65f6\u624d\u9002\u5408\u8c03\u7528pass\u51fd\u6570\u3002<br \/>\n03.\u53e6\u5916\uff0c\u9700\u8981\u6ce8\u610f\u7684\u4e00\u70b9\u662f\uff0cpass\u6a21\u5f0f\u4e0d\u80fd\u5904\u7406POST\u8bf7\u6c42\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f\u56e0\u4e3aPOST\u8bf7\u6c42\u4e00\u822c\u662f\u53d1\u9001<br \/>\n04.\u6570\u636e\u7ed9\u670d\u52a1\u5668\uff0c\u9700\u8981\u670d\u52a1\u5668\u63a5\u6536\u6570\u636e\uff0c\u5e76\u5904\u7406\u6570\u636e\uff0c\u53cd\u9988\u6570\u636e \u3002\u662f\u52a8\u6001\u7684\uff0c\u4e0d\u4f5c\u7f13\u5b58\u3002<br \/>\n05.\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b:<br \/>\n06.if (req.request !=&#8221;GET&#8221; &amp;&amp; req.request != &#8220;HEAD&#8221;)<br \/>\n07.{<\/p>\n<p>08.return (pipe);<\/p>\n<p>09.}<\/p>\n<p>10.\u90a3\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528pipe?\u7531\u4ee5\u4e0a\u9648\u8ff0\u53ef\u4ee5\u77e5\uff0c\u7c7b\u578b\u662fPOST\u65f6\u7528pipe\uff0c\u4f46\u662f\u4e5f\u8bb8\u8fd8\u4e0d\u592a\u6e05\u6670\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c<br \/>\n11.\u5f53\u5ba2\u6237\u7aef\u5728\u8bf7\u6c42\u4e00\u4e2a\u89c6\u9891\u6587\u4ef6\u65f6\uff0c\u6216\u8005\u4e00\u4e2a\u5927\u7684\u6587\u6863\uff0c\u5982.zip .tar \u6587\u4ef6\uff0c\u5c31\u9700\u8981\u7528pipe\u6a21\u5f0f\uff0c<br \/>\n12.\u8fd9\u4e9b\u5927\u7684\u6587\u4ef6\u662f\u4e0d\u88ab\u7f13\u5b58\u5728varnish\u4e2d\u7684\u3002<\/p>\n<p>01.\u4ec0\u4e48\u6837\u7684\u6570\u636e\u4f1a\u88ab\u7f13\u5b58\u5728varnish\u4e2d\u5462\uff1f<\/p>\n<p>02.\u7b54:varnish\u53ea\u7f13\u5b58\u9759\u6001\u6570\u636e\u3002\u5728\u7f51\u4e0a\u641c\u5230\u7684varnish\u7f13\u5b58\u7b56\u7565\uff0c\u53ef\u4ee5\u89e3\u7b54\u8fd9\u4e2a\u95ee\u9898\uff1a<br \/>\n03.varnish\u7f13\u5b58\u7b56\u7565<br \/>\n04.<br \/>\n05.\u7f3a\u7701\u662f\u6839\u6910\u540e\u7aef\u8fd4\u56de\u7684http\u72b6\u6001\u7801\u51b3\u5b9a\u662f\u5426\u7f13\u5b58\u3002\u53ef\u4ee5\u7f13\u5b58\u7684\u72b6\u6001\u7801\u5982\u4e0b\uff1a<br \/>\n06.200<\/p>\n<p>07.203<\/p>\n<p>08.300<\/p>\n<p>09.301<\/p>\n<p>10.302<\/p>\n<p>11.410<\/p>\n<p>12.404<\/p>\n<p>13.<br \/>\n14.varnish\u73b0\u5728\u8fd8\u4e0d\u652f\u6301ranges\u8bf7\u6c42\uff0c\u6240\u4ee5\u4e0d\u4f1a\u7f13\u5b58206\u72b6\u6001\u7684\u7ed3\u679c\u3002<br \/>\n15.<br \/>\n16.\u7ba1\u7406\u5458\u53ef\u4ee5\u5728vcl\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684vcl<em>fetch\u90e8\u5206\uff0c\u52a0\u5165\u81ea\u5df2\u7684\u7f13\u5b58\u7b56\u7565\uff0c\u65b9\u6cd5\u662f\u4fee\u6539beresp.cacheable\u53d8\u91cf\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\uff0c\u770b\u540e\u7aef\u8fd4\u56de\u4e2d\u5982\u679c\u8bbe\u7f6e\u4e86cookie\uff0c\u5219\u4e0d\u7f13\u5b58\uff1a<br \/>\n17.<br \/>\n18.sub fetch {<br \/>\n19.<br \/>\n20. if (beresp.http.Set-Cookie) {<br \/>\n21. set beresp.cacheable = false;<br \/>\n22. }<br \/>\n23.}<br \/>\n24.\u53c2\u8003\u6587\u7ae0\uff1ahttp:\/\/blog.sina.com.cn\/s\/blog<\/em>5374d6e30100tupo.html<\/p>\n<p>\u6587\u7ae0\u672b\u5c3e\u603b\u7ed3\uff1a\u5b66\u6280\u672f\u4e0d\u8981\u6b7b\u6263\u4e2d\u6587\u6587\u6863\uff0c\u591a\u770b\u82f1\u6587\u6587\u6863\u4f1a\u6bd4\u8f83\u6709\u5e2e\u52a9 \u3002<\/p>\n<p><!-- This document was created with MarkdownPad, the Markdown editor for Windows (http:\/\/markdownpad.com) --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2996","post","type-post","status-publish","format-standard","hentry","category-5","category-5-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2996"}],"version-history":[{"count":3,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2996\/revisions"}],"predecessor-version":[{"id":3116,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2996\/revisions\/3116"}],"wp:attachment":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}