Skip to content

Plugging in Plugins Yourself

Matt Holt edited this page Apr 23, 2019 · 6 revisions

You can build Caddy from source and plug in plugins without having to use the build server and without changing Caddy's source code! You need Go installed.

  1. Install Go if you don't have it already.
  2. Set the transitional environment variable for Go modules: export GO111MODULE=on
  3. Create a new folder anywhere (doesn't have to be in $GOPATH) - naming it caddy is preferred.
  4. Put this .go file into it, modifying it to import the plugins you want:
package main

import (
	"github.com/mholt/caddy/caddy/caddymain"
	
	// plug in plugins here, for example:
	// _ "import/path/here"
)

func main() {
	// optional: disable telemetry
	// caddymain.EnableTelemetry = false
	caddymain.Run()
}
  1. Make your little main function a Go module: go mod init caddy
  2. Then go install will then create your binary at $GOPATH/bin, or go build will put it in the current directory.
You can’t perform that action at this time.