layer4-proxy/README-EN.md

70 lines
2.0 KiB
Markdown
Raw Normal View History

2021-10-21 08:43:59 +00:00
# Fourth
> Hey, now we are on level 4!
2021-10-25 14:29:02 +00:00
[![](https://img.shields.io/crates/v/fourth)](https://crates.io/crates/fourth) [![CI](https://img.shields.io/github/workflow/status/kernelerr/fourth/Rust)](https://github.com/KernelErr/fourth/actions/workflows/rust.yml)
2021-10-26 15:58:00 +00:00
**Under heavy development, version 0.1 may update frequently**
2021-10-26 13:36:12 +00:00
Fourth is a layer 4 proxy implemented by Rust to listen on specific ports and transfer TCP/KCP data to remote addresses(only TCP) according to configuration.
2021-10-21 08:43:59 +00:00
## Features
- Listen on specific port and proxy to local or remote port
- SNI-based rule without terminating TLS connection
2021-10-26 15:02:05 +00:00
- Allow KCP inbound(warning: untested)
2021-10-21 08:43:59 +00:00
## Installation
To gain best performance on your computer's architecture, please consider build the source code. First, you may need [Rust tool chain](https://rustup.rs/).
```bash
$ cd fourth
$ cargo build --release
```
Binary file will be generated at `target/release/fourth`, or you can use `cargo install --path .` to install.
2021-10-26 13:40:40 +00:00
Or you can use Cargo to install Fourth:
```bash
$ cargo install fourth
```
2021-11-01 07:56:57 +00:00
Or you can download binary file form the Release page.
2021-10-21 08:43:59 +00:00
## Configuration
2021-11-01 08:06:47 +00:00
Fourth will read yaml format configuration file from `/etc/fourth/config.yaml`, and you can set custom path to environment variable `FOURTH_CONFIG`, here is an minimal viable example:
2021-10-21 08:43:59 +00:00
```yaml
version: 1
log: info
servers:
2021-11-01 07:25:12 +00:00
proxy_server:
2021-10-21 08:43:59 +00:00
listen:
- "127.0.0.1:8081"
default: remote
upstream:
2021-11-01 07:25:12 +00:00
remote: "tcp://www.remote.example.com:8082" # proxy to remote address
2021-10-21 08:43:59 +00:00
```
2021-11-01 07:25:12 +00:00
Built-in two upstreams: ban(terminate connection immediately), echo. For detailed configuration, check [this example](./example-config.yaml).
## Performance Benchmark
Tested on 4C2G server:
Use fourth to proxy to Nginx(QPS of direct connection: ~120000): ~70000 req/s (Command: `wrk -t200 -c1000 -d120s --latency http://proxy-server:8081`)
Use fourth to proxy to local iperf3: 8Gbps
2021-10-21 08:43:59 +00:00
2021-10-26 15:02:05 +00:00
## Thanks
- [tokio_kcp](https://github.com/Matrix-Zhang/tokio_kcp)
2021-10-21 08:43:59 +00:00
## License
Fourth is available under terms of Apache-2.0.