|
| 1 | +# GoHPTS - HTTP proxy to SOCKS5 proxy written in Go |
| 2 | + |
| 3 | +[](https://opensource.org/licenses/MIT) |
| 4 | +[](https://pkg.go.dev/github.com/shadowy-pycoder/go-http-proxy-to-socks) |
| 5 | + |
| 6 | +[](https://goreportcard.com/report/github.com/shadowy-pycoder/go-http-proxy-to-socks) |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +## Introduction |
| 11 | + |
| 12 | +`GoHPTS` CLI tool is a bridge between HTTP clients and a SOCKS5 proxy server. It listens locally as an HTTP proxy, accepts standard HTTP |
| 13 | +or HTTPS (via CONNECT) requests and forwards the connection through a SOCKS5 proxy. Inspired by [http-proxy-to-socks](https://github.com/oyyd/http-proxy-to-socks) |
| 14 | + |
| 15 | +Possible use case: you need to connect to external API via Postman, but this API only available from some remote server. |
| 16 | +The following commands will help you to perform such a task: |
| 17 | + |
| 18 | +Create SOCKS5 proxy server via `ssh`: |
| 19 | + |
| 20 | +```shell |
| 21 | +ssh <remote server> -D 1080 -Nf |
| 22 | +``` |
| 23 | + |
| 24 | +Create HTTP-to-SOCKS5 connection with `gohpts` |
| 25 | + |
| 26 | +```shell |
| 27 | +gohpts -s :1080 -l :8080 |
| 28 | +``` |
| 29 | + |
| 30 | +Specify http server in proxy configuration of Postman |
| 31 | + |
| 32 | +## Installation |
| 33 | + |
| 34 | +You can download the binary for your platform from [Releases](https://github.com/shadowy-pycoder/go-http-proxy-to-socks/releases) page. |
| 35 | + |
| 36 | +Alternatively, you can install it using `go install` command (requires Go [1.24](https://go.dev/doc/install) or later): |
| 37 | + |
| 38 | +```shell |
| 39 | +go install -ldflags "-s -w" -trimpath github.com/shadowy-pycoder/go-http-proxy-to-socks/cmd/gohpts@latest |
| 40 | +``` |
| 41 | + |
| 42 | +This will install the `gohpts` binary to your `$GOPATH/bin` directory. |
| 43 | + |
| 44 | +Another alternative is to build from source: |
| 45 | + |
| 46 | +```shell |
| 47 | +git clone https://github.com/shadowy-pycoder/go-http-proxy-to-socks.git |
| 48 | +cd go-http-proxy-to-socks |
| 49 | +make build |
| 50 | +./bin/gohpts |
| 51 | +``` |
| 52 | + |
| 53 | +## Usage |
| 54 | + |
| 55 | +```shell |
| 56 | +gohpts -h |
| 57 | + |
| 58 | + _____ _ _ _____ _______ _____ |
| 59 | + / ____| | | | | __ \__ __/ ____| |
| 60 | + | | __ ___ | |__| | |__) | | | | (___ |
| 61 | + | | |_ |/ _ \| __ | ___/ | | \___ \ |
| 62 | + | |__| | (_) | | | | | | | ____) | |
| 63 | + \_____|\___/|_| |_|_| |_| |_____/ |
| 64 | + |
| 65 | +GoHPTS (HTTP Proxy to SOCKS5) by shadowy-pycoder |
| 66 | +GitHub: https://github.com/shadowy-pycoder/go-http-proxy-to-socks |
| 67 | + |
| 68 | +Usage: gohpts [OPTIONS] |
| 69 | +Options: |
| 70 | + -h Show this help message and exit. |
| 71 | + -d Show logs in DEBUG mode |
| 72 | + -j Show logs in JSON format |
| 73 | + -l value |
| 74 | + Address of HTTP proxy server (Default: localhost:8080) |
| 75 | + -s value |
| 76 | + Address of SOCKS5 proxy server (Default: localhost:1080) |
| 77 | + -v print version |
| 78 | + |
| 79 | +``` |
| 80 | + |
| 81 | +## Example |
| 82 | + |
| 83 | +```shell |
| 84 | +gohpts -s 1080 -l 8080 -d -j |
| 85 | +``` |
| 86 | + |
| 87 | +Output: |
| 88 | + |
| 89 | +```shell |
| 90 | +{"level":"info","time":"2025-05-28T06:15:18+00:00","message":"SOCKS5 Proxy: :1080"} |
| 91 | +{"level":"info","time":"2025-05-28T06:15:18+00:00","message":"HTTP Proxy: :8080"} |
| 92 | +{"level":"debug","time":"2025-05-28T06:15:22+00:00","message":"HTTP/1.1 - CONNECT - www.google.com:443"} |
| 93 | +``` |
| 94 | + |
| 95 | +## License |
| 96 | + |
| 97 | +MIT |
0 commit comments