﻿{"id":378,"date":"2016-05-11T15:25:21","date_gmt":"2016-05-11T07:25:21","guid":{"rendered":"http:\/\/blog.sway.com.cn\/?p=378"},"modified":"2016-06-04T23:01:18","modified_gmt":"2016-06-04T15:01:18","slug":"lighttpd%e6%b7%bb%e5%8a%a0%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"http:\/\/blog.sway.com.cn\/?p=378","title":{"rendered":"lighttpd\u6dfb\u52a0\u53cd\u5411\u4ee3\u7406\u529f\u80fd"},"content":{"rendered":"<p>1\u3001\u542f\u7528lighttpd\u7684\u53cd\u5411\u4ee3\u7406\u6a21\u5757\uff1a<\/p>\n<p>\u7f16\u8f91\/etc\/lighttpd\/modules.conf\u6587\u4ef6\uff0c\u627e\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:default mark:4 decode:true \">##\r\n## mod_proxy\r\n##\r\n#include \"conf.d\/proxy.conf\"<\/pre>\n<p>\u53bb\u6389\u4ee5\u4e0b\u4ee3\u7801\u5f00\u5934\u7684\u201c#\u201d\u53f7\u5373\u53ef<\/p>\n<pre class=\"lang:default mark:4 decode:true\">#include \"conf.d\/proxy.conf\"<\/pre>\n<p>2\u3001\u7f16\u8f91\/etc\/lighttpd\/lighttpd.conf\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:default decode:true\">#tomcat\r\n\r\n$HTTP[\"host\"] =~ \"(abc\\.com|www\\.abc\\.com)$\" {\r\n\tproxy.balance = \"hash\" \r\n\tproxy.server  = ( \"\" =&gt; ( ( \"host\" =&gt; \"127.0.0.1\", \"port\" =&gt; 8080 ) ) )\r\n}<\/pre>\n<p>3\u3001\u91cd\u542flighttpd\u670d\u52a1\u5668<\/p>\n<pre class=\"lang:default decode:true \">service lighttpd restart<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5173\u4e8e\u5339\u914d\u7b26\u7684\u521d\u6b65\u7406\u89e3\uff1a<\/p>\n<p>== \u610f\u5473\u7740\u5339\u914d\u89c4\u5219\u5c06\u4f7f\u7528\u666e\u901a\u7684\u65b9\u6cd5<\/p>\n<p>=~ \u610f\u5473\u7740\u5339\u914d\u89c4\u5219\u5c06\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff1f\uff08\u672a\u786e\u5b9a\uff09<\/p>\n<p>!~ \u610f\u5473\u7740\u4e0d\u5339\u914d\u89c4\u5219\u5c06\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/p>\n<p>^\u8868\u793a\u5f00\u5934<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5176\u4ed6\u7684\u4e00\u4e9b\u914d\u7f6e\u53c2\u8003\uff1a<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:java decode:true\">$HTTP[\"host\"] =~ \"(sway\\.com\\.cn|www\\.sway\\.com\\.cn)$\" {\r\n\tserver.document-root = \"\/home\/xinsiwei.20150120.igongcha\/ROOT\"\r\n\t$HTTP[\"url\"] !~ \"\\.(gif|jpg|png|txt|html|css|js|swf)$\" {\r\n\t\tproxy.server  = ( \"\/\" =&gt; ( ( \"host\" =&gt; \"127.0.0.1\", \"port\" =&gt; 8128 ) ) )\r\n\t}\r\n}<\/pre>\n<p>\u8fd9\u4e2a\u7684\u610f\u601d\u662f\uff0c\u9664\u4e86gif|jpg|png|txt|html|css|js|swf\u5916\uff0c\u5176\u4f59\u8bf7\u6c42\u5168\u90e8\u8f6c\u53d1\u5230127.0.0.1:8128\u7aef\u53e3\u4e0a\u53bb<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:java decode:true\">$HTTP[\"host\"] == \"liaoxuefeng.com\" {\r\n    url.redirect = ( \"^\/(.*)\" =&gt; \"http:\/\/www.sway.com.cn\/$1\" )\r\n}<\/pre>\n<p>\u8fd9\u4e2a\u7684\u610f\u601d\u662f\uff0c\u6240\u6709\u57df\u540d\u4e3aliaoxuefeng.com\u7684\u8bf7\u6c42\uff0c\u5168\u90e8\u8df3\u8f6c\u5230http:\/\/www.liaoxuefeng.com\/\u4e0a\u53bb\uff0c\u5e76\u4e14\u81ea\u52a8\u5339\u914d\u5e76\u8865\u5145url\u5730\u5740<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:java decode:true\">$HTTP[\"host\"] == \"www.sway.com.cn\" {\r\n    server.name = \"www.sway.com.cn\"\r\n    server.document-root = \"\/home\/www\/sway\/\"\r\n\r\n    $HTTP[\"url\"] !~ \"^(favicon.ico|.*\/static\/.*)$\" {\r\n        proxy.server = ( \"\" =&gt; (( \"host\" =&gt; \"127.0.0.1\", \"port\" =&gt; 8000 )))\r\n    }\r\n}<\/pre>\n<p>\u8fd9\u4e2a\u7684\u610f\u601d\u662f\uff0c\u9664\u4e86favicon.ico\u53ca\u6587\u4ef6\u5939\u4e3a\/static\/\u7684url\u5916\uff0c\u5c06\u5168\u90e8\u8bf7\u6c42\u8f6c\u53d1\u52308000\u7aef\u53e3\u4e0a<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u542f\u7528lighttpd\u7684\u53cd\u5411\u4ee3\u7406\u6a21\u5757\uff1a \u7f16\u8f91\/etc\/lighttpd\/modules.conf\u6587\u4ef6\uff0c\u627e\u5230\u4ee5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[143],"class_list":["post-378","post","type-post","status-publish","format-standard","hentry","category-lighttpd","tag-lighttpd"],"_links":{"self":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=378"}],"version-history":[{"count":5,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/378\/revisions"}],"predecessor-version":[{"id":398,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/378\/revisions\/398"}],"wp:attachment":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}