Update README.md to Caddy v2 with Caddyfile

This commit is contained in:
klzgrad 2020-09-27 04:40:39 +08:00 committed by GitHub
parent 4a944da697
commit abc2387bd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,63 +37,21 @@ git clone -b naive https://github.com/klzgrad/forwardproxy
go get -u github.com/caddyserver/xcaddy/cmd/xcaddy go get -u github.com/caddyserver/xcaddy/cmd/xcaddy
~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy=$PWD/forwardproxy ~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy=$PWD/forwardproxy
sudo setcap cap_net_bind_service=+ep ./caddy sudo setcap cap_net_bind_service=+ep ./caddy
./caddy run --config caddy.json
``` ```
Then `./caddy run` with the following Caddyfile (replace the example values accordingly):
<details> ```
<summary>Example caddy.json using Let's Encrypt (replace example values accordingly)</summary> :443, example.com
tls me@example.com
```json route {
{ forward_proxy {
"admin": {"disabled": true}, basicauth user pass
"logging": { hide_ip
"sink": {"writer": {"output": "discard"}}, hide_via
"logs": {"default": {"writer": {"output": "discard"}}} probe_resistance secret.com
},
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [":443"],
"routes": [{
"handle": [{
"handler": "forward_proxy",
"hide_ip": true,
"hide_via": true,
"auth_user": "username",
"auth_pass": "password",
"probe_resistance": {"domain": "use a secret name or empty string here:0"}
}]
}, {
"match": [{"host": ["example.com", "www.example.com"]}],
"handle": [{
"handler": "file_server",
"root": "/var/www/html"
}],
"terminal": true
}],
"tls_connection_policies": [{
"match": {"sni": ["example.com", "www.example.com"]}
}]
}
}
},
"tls": {
"automation": {
"policies": [{
"subjects": ["example.com", "www.example.com"],
"issuer": {
"email": "admin@example.com",
"module": "acme"
}
}]
}
}
} }
file_server { root /var/www/html }
} }
``` ```
</details>
Locally run `./naive` with the following `config.json` to get a SOCKS5 proxy at local port 1080. Locally run `./naive` with the following `config.json` to get a SOCKS5 proxy at local port 1080.
```json ```json