HTTP proxy through SSH SOCKS5 tunnel
npm install ssh-chainHTTP proxy through SSH SOCKS5 tunnel.
``bash`
pnpm install
Build the project (requires Bun for building):
`bash`
bun run build
This creates:
- dist/ssh-chain - Executable that runs with Node.js (recommended)dist/ssh-chain.bun
- Requires Node.js in runtime
- Smaller size (~400KB)
- No known bugs
- - Bun-specific binary
- Standalone binary (no runtime required)
- Larger size (~100MB)
- Known bug: incorrect byte usage display
Note: We recommend using Node.js to run the built binary due to a Bun issue with memory statistics.
`bashConnect using ~/.ssh/config host
./dist/ssh-chain my-server
$3
`bash
Use default config.json
./dist/ssh-chainUse custom config file
./dist/ssh-chain -c ./path/to/config.jsonOverride sshServer from config file
./dist/ssh-chain other-server -c ./path/to/config.json
`$3
`
Usage:
ssh-chain [options] [ssh-server]Arguments:
ssh-server SSH host (hostname, IP, or ~/.ssh/config Host entry)
This overrides sshServer in config file
Options:
-c, --config Path to config file (default: ./config.json)
-p, --port HTTP proxy port (default: 4080)
-l, --log-level Log level: debug, info, warn, error (default: info)
-h, --help Show help message
-v, --version Show version
`$3
`bash
Simple usage
./dist/ssh-chain my-serverCustom HTTP proxy port
./dist/ssh-chain my-server -p 8080Enable debug logging
./dist/ssh-chain my-server --log-level debugUse custom config with server override
./dist/ssh-chain other-server -c ./custom-config.json
`Configuration
See config.example.json for all available options.
The only required configuration is
sshServer, which can be provided:- As a command-line argument
- In the config file
Command-line arguments have higher priority than config file values.
$3
You can configure domains that should bypass the proxy and connect directly. Add them to the
directDomains array in your config file:`json
{
"directDomains": ["foo.example.com", ".my-company.com", "foo-bar", ".us"]
}
`Wildcard Support:
- Exact match:
foo.example.com - only matches this exact domain
- Subdomain wildcard: *.my-company.com - matches any subdomain like api.my-company.com, dev.api.my-company.com, and the apex domain my-company.com
- No TLD: foo-bar - matches simple hostnames without a TLD
- TLD wildcard: *.us - matches all domains ending in .us (e.g., example.us, api.example.us)Direct connections are labeled with
[DIRECT] in the logs.Development
This project requires Bun for building and development:
`bash
Install dependencies
pnpm installRun in development mode (with auto-reload)
bun run devRun tests
bun testType check
pnpm typecheckBuild for production
bun run build
``