4Chain

What is 4chain?

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─────────────────────┘                                                                       
                                                                                                                                                   

Feature

Quick start

  1. map the local listening port 8082 to the public network via 4chain.me

$ ssh -R 443::8082 4chain.me
  1. After establishing a successful remote SSH connection, the public access URL is returned https://0u6rq7.4chain.me

  2. Access from the public network

    curl https://0u6rq7.4chain.me

Deploy

Preparation:

  • domain name 4chain.me
  • server IP 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"
}
  1. Configure cloudflare dns resolution

    A 4chain.me 157.xxx.xx.xx
    A *.4chain.me 157.xxx.xx.xx
  1. Get cloudflare token to the cf_token field of config.json

  2. 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 
  1. start 4chain

#.
#├── 4chain
#└── config.json
#

$  ./4chain

TODO

  • Support windows

Developer

License

BSD

Other

Deepl

GitHub

https://github.com/4chain/edge