Skip to content

Caddy Plugin to use websockets as a bridge to TCP sockets

Notifications You must be signed in to change notification settings

Incubaid/wsproxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Caddy wsproxy plugin

This plugin act as a bridge between web sockets and TCP sockets to enable frontend apps to access to TCP sockets through web sockets.

Installation

You can add the plugin to caddy source manually or using caddyman

1 - Manual Installation
  • 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 into plugin.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
2 - Using Caddyman
git clone https://github.com/Incubaid/caddyman.git
cd caddman
./caddyman.sh install wsproxy

Plugin Usage

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
}

About

Caddy Plugin to use websockets as a bridge to TCP sockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%