This plugin act as a bridge between web sockets and TCP sockets to enable frontend apps to access to TCP sockets through web sockets.
You can add the plugin to caddy source manually or using caddyman
- Get plugin files:
go get github.com/incubaid/wsproxy
- Import plugin into caddy
run.go
file:$GOPATH/src/github.com/mholt/caddy/caddy/caddymain/run.go
package caddymain
import (
//.......
// This is where other plugins get plugged in (imported)
// ......
_ "github.com/incubaid/wsproxy"
)
- Register
wsproxy
directive by adding it intoplugin.go
file:$GOPATH/src/github.com/mholt/caddy/caddyhttp/httpserver/plugin.go
package httpserver
// .......
var directives = []string{
//........
"wsproxy",
//............
}
- Rebuild Caddy
cd $GOPATH/src/github.com/mholt/caddy/caddy/
go run build.go
git clone https://github.com/Incubaid/caddyman.git
cd caddman
./caddyman.sh install wsproxy
In your caddy file use the wsproxy
directive:
wsproxy [PATH] TCP_SOCKET_ADDRESS
where:
PATH
is the server path which will start websocket connection, if ommited it will match /
TCP_SOCKET_ADDRESS
is the tcp socket address needs to connect to.
Example:
http://localhost:8200 {
wsproxy /redis localhost:6379
}