{"id":743,"date":"2020-08-20T16:39:44","date_gmt":"2020-08-20T08:39:44","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=743"},"modified":"2020-08-20T16:39:46","modified_gmt":"2020-08-20T08:39:46","slug":"add-plug-ins-in-caddy-v1-version","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/","title":{"rendered":"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6"},"content":{"rendered":"\n

caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6<\/p>\n\n\n\n

\u4e00\u3001 \u5b89\u88c5GO \u56fd\u5185\u9700\u8bbe\u7f6e\u4ee3\u7406#
# go \u5b89\u88c5\u6587\u6863
https:\/\/golang.org\/doc\/install
# \u542f\u7528 Go Modules \u529f\u80fd
go env -w GO111MODULE=on<\/p>\n\n\n\n

 # \u914d\u7f6e GOPROXY \u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4e0b\u4e09\u9009\u4e00\n\n # 1. \u5b98\u65b9\n go env -w  GOPROXY=https:\/\/goproxy.io\n\n # 2. \u4e03\u725b CDN\n go env -w  GOPROXY=https:\/\/goproxy.cn\n\n # 3. \u963f\u91cc\u4e91\n go env -w GOPROXY=https:\/\/mirrors.aliyun.com\/goproxy\/<\/code><\/pre>\n\n\n\n

\u4e8c\u3001 \u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\uff0c\u540d\u5b57\u968f\u610f
mkdir \/root\/caddy
#\u7f16\u8f91.go \u6587\u4ef6
vim caddy.go<\/p>\n\n\n\n

package main\nimport (\n        \"github.com\/caddyserver\/caddy\/caddy\/caddymain\"\n        _ \"github.com\/pyed\/ipfilter\"  #\u8fd9\u91cc\u5c31\u662f\u4f60\u9700\u8981\u6dfb\u52a0\u7684\u63d2\u4ef6\n\n        \/\/ plug in plugins here, for example:\n        \/\/ _ \"import\/path\/here\"\n)\n\nfunc main() {\n        \/\/ optional: disable telemetry\n        \/\/ caddymain.EnableTelemetry = false\n        caddymain.Run()\n}\n\n#go \u6a21\u5757\ngo mod init caddy\n\n#\u7136\u540ego install\u5c06\u5728$ GOPATH \/ bin\u4e2d\u521b\u5efa\u60a8\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u6216\u8005go build\u5c06\u5176\u653e\u5165\u5f53\u524d\u76ee\u5f55\u4e2d<\/code><\/pre>\n\n\n\n

\u4e09\u3001 \u66ff\u6362caddy \u4e8c\u8fdb\u5236\u6587\u4ef6
\u4e00\u822c\u5728\/usr\/local\/bin\/caddy
\u91cd\u542fcaddy\u94fe\u63a5\uff1a
caddy github :https:\/\/github.com\/caddyserver\/caddy\/wiki\/Plugging-in-Plugins-Yourself
go wiki : https:\/\/learnku.com\/go\/wikis\/38122go doc :https:\/\/golang.org\/doc\/install
 http.ipfilter \u63d2\u4ef6 https:\/\/github.com\/pyed\/ipfilter<\/p>\n","protected":false},"excerpt":{"rendered":"

caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 \u4e00\u3001 \u5b89\u88c5GO \u56fd\u5185\u9700\u8bbe\u7f6e\u4ee3\u7406## go \u5b89\u88c5\u6587\u6863https:\/\/golang<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,18],"tags":[],"yoast_head":"\nCaddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\" \/>\n<meta property=\"og:description\" content=\"caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 \u4e00\u3001 \u5b89\u88c5GO \u56fd\u5185\u9700\u8bbe\u7f6e\u4ee3\u7406## go \u5b89\u88c5\u6587\u6863https:\/\/golang\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-20T08:39:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-20T08:39:46+00:00\" \/>\n<meta name=\"author\" content=\"\u7ba1\u7406\u5458\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/\"},\"author\":{\"name\":\"\u7ba1\u7406\u5458\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"headline\":\"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6\",\"datePublished\":\"2020-08-20T08:39:44+00:00\",\"dateModified\":\"2020-08-20T08:39:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/\"},\"wordCount\":63,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"articleSection\":[\"Linux\",\"Linux\u670d\u52a1\"],\"inLanguage\":\"zh-CN\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/\",\"url\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/\",\"name\":\"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\",\"isPartOf\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#website\"},\"datePublished\":\"2020-08-20T08:39:44+00:00\",\"dateModified\":\"2020-08-20T08:39:46+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/#breadcrumb\"},\"inLanguage\":\"zh-CN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.linuxdevops.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\",\"item\":\"https:\/\/www.linuxdevops.cn\/linux\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#website\",\"url\":\"https:\/\/www.linuxdevops.cn\/\",\"name\":\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\",\"description\":\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\u7b14\u8bb0\",\"publisher\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"alternateName\":\"linuxdevops\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.linuxdevops.cn\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-CN\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\",\"name\":\"\u7ba1\u7406\u5458\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-CN\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg\",\"contentUrl\":\"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg\",\"width\":512,\"height\":512,\"caption\":\"\u7ba1\u7406\u5458\"},\"logo\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/\"},\"description\":\"\u7ba1\u7406\u5458\",\"url\":\"https:\/\/www.linuxdevops.cn\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/","og_locale":"zh_CN","og_type":"article","og_title":"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","og_description":"caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 \u4e00\u3001 \u5b89\u88c5GO \u56fd\u5185\u9700\u8bbe\u7f6e\u4ee3\u7406## go \u5b89\u88c5\u6587\u6863https:\/\/golang","og_url":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/","og_site_name":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","article_published_time":"2020-08-20T08:39:44+00:00","article_modified_time":"2020-08-20T08:39:46+00:00","author":"\u7ba1\u7406\u5458","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/#article","isPartOf":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/"},"author":{"name":"\u7ba1\u7406\u5458","@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"headline":"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6","datePublished":"2020-08-20T08:39:44+00:00","dateModified":"2020-08-20T08:39:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/"},"wordCount":63,"commentCount":0,"publisher":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"articleSection":["Linux","Linux\u670d\u52a1"],"inLanguage":"zh-CN","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/","url":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/","name":"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","isPartOf":{"@id":"https:\/\/www.linuxdevops.cn\/#website"},"datePublished":"2020-08-20T08:39:44+00:00","dateModified":"2020-08-20T08:39:46+00:00","breadcrumb":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/#breadcrumb"},"inLanguage":"zh-CN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/add-plug-ins-in-caddy-v1-version\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.linuxdevops.cn\/"},{"@type":"ListItem","position":2,"name":"Linux","item":"https:\/\/www.linuxdevops.cn\/linux\/"},{"@type":"ListItem","position":3,"name":"Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6"}]},{"@type":"WebSite","@id":"https:\/\/www.linuxdevops.cn\/#website","url":"https:\/\/www.linuxdevops.cn\/","name":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","description":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\u7b14\u8bb0","publisher":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"alternateName":"linuxdevops","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.linuxdevops.cn\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-CN"},{"@type":["Person","Organization"],"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1","name":"\u7ba1\u7406\u5458","image":{"@type":"ImageObject","inLanguage":"zh-CN","@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/","url":"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg","contentUrl":"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg","width":512,"height":512,"caption":"\u7ba1\u7406\u5458"},"logo":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/"},"description":"\u7ba1\u7406\u5458","url":"https:\/\/www.linuxdevops.cn\/author\/root\/"}]}},"_links":{"self":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/743"}],"collection":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/comments?post=743"}],"version-history":[{"count":1,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":744,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/743\/revisions\/744"}],"wp:attachment":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/media?parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/categories?post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/tags?post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}