Friday, August 3, 2018

How to enable external Caddy Plugins

The below explains how to enabled external caddy plugins. Here, caddyserver/forwardproxy plugin is being enabled.
First, get Golang:
cd /usr/local &&
curl -s -L -O https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
tar -xvzf go1.10.1.linux-amd64.tar.gz
Next, add the following ~/.bash_profile:
export GOPATH=$HOME/go
export GOBIN=$HOME/go/bin
export GOROOT=/usr/local/go
Also, add GOBIN to the PATH environment variable:
PATH=$GOBIN:$PATH
export PATH
After this step, you have Golang compiler ready in /usr/local/go/bin/ directory:
# /usr/local/go/bin/go version
go version go1.10.1 linux/amd64
Download the source code of caddy and caddyserver/forwardproxy plugin:
go get github.com/mholt/caddy/caddy
go get github.com/caddyserver/builds
go get github.com/caddyserver/forwardproxy
Add a reference to caddyserver/forwardproxy plugin in caddy source code. Find "This is where other plugins get plugged in" in $GOPATH/src/github.com/mholt/caddy/caddy/caddymain/run.go file and add a reference to the plugin.
_ "github.com/caddyserver/forwardproxy"
Finally, build caddy binary:
cd $GOPATH/src/github.com/mholt/caddy/caddy
go run build.go
caddy --version
The http.forwardproxy plugin is in the list of enabled plugins:
# caddy -plugins
Server types:
  http
Caddyfile loaders:
  short
  flag
  default
Other plugins:
  http.forwardproxy

Labels: , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home