MENU

Forwarding unix socket to a tcp connection.

March 9, 2024 • Linux,Network

sock2tcp

cover2.png

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

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
UNIX_SOCKET_PATH=/path/to/socket
TCP_BIND_ADDRESS=0.0.0.0:8080
  1. use environment variables to configure the server
export UNIX_SOCKET_PATH=/path/to/socket
export TCP_BIND_ADDRESS=0.0.0.0:8080
./sock2tcp
  1. use docker container.
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
Last Modified: September 3, 2024