Featured image of post Forwarding unix socket to a tcp connection.

Forwarding unix socket to a tcp connection.

sock2tcp, a tool that can forwarding unix socket to a tcp connection.

sock2tcp

sock2tcp is a simple tool to forward a local socket to serve as a TCP server. It is useful when you have a local socket and you want to expose it to specific IP and port.

Installation

1
go install github.com/evsio0n/sock2tcp

Usage

  1. use .env file to configure the server
ParameterDescription
UNIX_SOCKET_PATHThe path of the local socket
TCP_BIND_ADDRESSThe port to expose the socket
1
2
UNIX_SOCKET_PATH=/path/to/socket
TCP_BIND_ADDRESS=0.0.0.0:8080
  1. use environment variables to configure the server
1
2
3
export UNIX_SOCKET_PATH=/path/to/socket
export TCP_BIND_ADDRESS=0.0.0.0:8080
./sock2tcp 
  1. use docker container.
1
docker run -v /tmp/mysql.sock:/tmp/mysql.sock -e "UNIX_SOCKET_PATH=/tmp/mysql.sock" -e "TCP_BIND_ADDRESS=0.0.0.0:3306" -p 3306 ghcr.io/evsio0n/sock2tcp:latest
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
33135a60-master at 2024-03-09 15:10:22 +0000
Built with Hugo
Theme Stack designed by Jimmy