simple reverse proxy tool in go
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-12-22 23:42:15 +08:00
.gitignore document redirect-https branch 2024-08-19 22:03:00 +08:00
certloader.go feat: rewrite 2025-12-22 18:35:04 +08:00
go.mod lower go version in go.mod to 1.17 2024-07-04 15:56:57 +08:00
LICENSE Initial commit 2024-07-02 12:22:53 +00:00
main.go feat: rewrite 2025-12-22 18:35:04 +08:00
main_test.go add tls support, reorganize code, modify docs 2024-07-22 12:41:23 +08:00
misc.go feat: rewrite 2025-12-22 18:35:04 +08:00
README.md feat: rewrite 2025-12-22 18:35:04 +08:00
revproxy.go fix: close certLoader only if not nil 2025-12-22 23:42:15 +08:00

revproxy

Simple reverse proxy for TCP and Unix sockets.

Get Started

Build go build
Usage ./revproxy <listen-net> <listen-addr> <dial-net> <dial-addr> [bufsize] [cert] [key]

See go docs for available listen & dial networks, and address format:

You can specify buffer size with a unit. The default is 4k.

Examples

  • revproxy tcp 127.0.0.1:25565 tcp example.com:25565 1k
  • revproxy tcp [::]:443 tcp 192.168.1.100:8080 4k fullchain.pem privkey.pem

TLS

With paths to TLS cert and key files, it serves on TLS connections.

This is useful for smtp on tls, xmpp on tls, or simple https.

It automatically reloads cert files within 24 hours if they are modified.

Q&A

How about socat?

Example socat command for a similar reverse proxy:

socat tcp-listen:80,fork,reuseaddr,keepalive,keepidle=10,keepintvl=30,keepcnt=2 tcp:localhost:8080

In contrast, this program allows you to use TLS and specify a buffer size, and it uses goroutines instead of fork.

Is this ready for proxying HTTP server?

It doesn’t touch HTTP headers, so there isn’t X-Forwarded-For, which may affect logging. Complex servers may not work well.

This is free and unencumbered software released into the public domain. https://unlicense.org/