ssh reverse proxy
BSD-3-CLAUSE License
4chain is a simple、fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet.
Using the ssh protocol means that Linux, macOS can quickly connect using the ssh
command, and windows can connect using ?
Request
┌───────────────dispatch: foo───────────┐
│ │
│ │
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ┌ ─ ─ ─ ─│─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
Host Node │ │ │ Exit Node │
│ ▼ │ │
┌───────────┐ ┌────────┐ │ .─────. ┌────────┐ ┌──────────────┴────────┐ .─────. ┌─────────┐
│ │ Node │ │ │ ╱ ╲ │ │ │ │ │ ╱ ╲ │ │
│http://127.│◀ ─ ─ ▶│ client │◀═══╬═══▶( SSH )◀════════▶│ Server │◀ ─ ─ ─▶│http(s)://foo.4chain.me│◀ ─ ─▶(internet )◀─ ─ ▶│ Browser │
│ │0.0.1:3000 │ │ │ `. ,' │ │ │ │ │ `. ,' │ │
└───────────┘ └────────┘ │ `───' └────────┘ └──────────────┬────────┘ `───' └─────────┘
│ │ │ ▲
Private IPv4 │ │ │ │
│ │ │ │
─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│─ ─ ─ ─ ┘ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
│ Response │
└────────────────OK─────────────────────┘
$ ssh -R 443::8082 4chain.me
After establishing a successful remote SSH connection, the public access URL is returned https://0u6rq7.4chain.me
Access from the public network
curl https://0u6rq7.4chain.me
Preparation:
4chain.me
157.xxx.xx.xx
{
"addr": ":443",
"email": "[email protected]",
"cf_token": "xxx",
"ssh_addr": ":22",
"domain": "4chain.me", # change you domain
"idle_timeout": 300,
"key": "-----BEGIN OPENSSH PRIVATE KEY-----\nxxxxxx\n-----END OPENSSH PRIVATE KEY-----\n"
}
A 4chain.me 157.xxx.xx.xx
A *.4chain.me 157.xxx.xx.xx
Get cloudflare token to the cf_token field of config.json
generator ssh key:
$ ssh-keygen -b 2048 -f 4chain_rsa
$ cat 4chain_rsa #Copy the contents of the generated private key to the key field of config.json
#.
#├── 4chain
#└── config.json
#
$ ./4chain