{"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":"\n
Caddy v1 \u7248\u672c\u589e\u52a0\u63d2\u4ef6 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n