Skip to content

Commit

Permalink
docs: add transparent proxy demo
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Dec 7, 2024
1 parent 767df00 commit 27503f2
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 2 deletions.
17 changes: 15 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# examples

# Examples

## Static-Server

Expand Down Expand Up @@ -37,3 +36,17 @@ The key points of configuration are as follows:
```bash
cargo run -- -c=~/github/pingap/examples/grpc-web.toml --admin=127.0.0.1:3018
```

## Transparent Proxy

- Upstream discovery should be `transparent`
- Upstream sni should be `$host` for https
- Certificate should be set as default for all domains

```bash
sudo cargo run -- -c=~/github/pingap/examples/transparent-proxy.toml --admin=127.0.0.1:3018
```

```bash
curl -kv --resolve '*:443:127.0.0.1' 'https://cn.bing.com/'
```
72 changes: 72 additions & 0 deletions examples/transparent-proxy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[upstreams.transparentUpstream]
addrs = ["127.0.0.1"]
discovery = "transparent"
sni = "$host"

[locations.transparentLocation]
upstream = "transparentUpstream"

[servers.test]
addr = "127.0.0.1:443"
locations = ["transparentLocation"]
global_certificates = true

[certificates.medev]
tls_cert = """
-----BEGIN CERTIFICATE-----
MIIEljCCAv6gAwIBAgIQeYUdeFj3gpzhQes3aGaMZTANBgkqhkiG9w0BAQsFADCB
pTEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMT0wOwYDVQQLDDR4aWVz
aHV6aG91QHhpZXNodXpob3VzLU1hY0Jvb2stQWlyLmxvY2FsICjosKLmoJHmtLIp
MUQwQgYDVQQDDDtta2NlcnQgeGllc2h1emhvdUB4aWVzaHV6aG91cy1NYWNCb29r
LUFpci5sb2NhbCAo6LCi5qCR5rSyKTAeFw0yMzA5MjQxMzA1MjdaFw0yNTEyMjQx
MzA1MjdaMGgxJzAlBgNVBAoTHm1rY2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0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RyqC/a/wKBgQDAtLXUsCABQDTPHdy/M/dHZA/QQ/xU8NOs
ul5UMJCkSfFNk7b2etQG/iLlMSNup3bY3OPvaCGwwEy/gZ31tTSymgooXQMFxJ7G
1S/DF45yKD6xJEmAUhwz/Hzor1cM95g78UpZFCEVMnEmkBNb9pmrXRLDuWb0vLE6
B6YgiEP6xQKBgBOXuooVjg2co6RWWIQ7WZVV6f65J4KIVyNN62zPcRaUQZ/CB/U9
Xm1+xdsd1Mxa51HjPqdyYBpeB4y1iX+8bhlfz+zJkGeq0riuKk895aoJL5c6txAP
qCJ6EuReh9grNOFvQCaQVgNJsFVpKcgpsk48tNfuZcMz54Ii5qQlue29AoGAA2Sr
Nv2K8rqws1zxQCSoHAe1B5PK46wB7i6x7oWUZnAu4ZDSTfDHvv/GmYaN+yrTuunY
0aRhw3z/XPfpUiRIs0RnHWLV5MobiaDDYIoPpg7zW6cp7CqF+JxfjrFXtRC/C38q
MftawcbLm0Q6MwpallvjMrMXDwQrkrwDvtrnZ4kCgYEA0oSvmSK5ADD0nqYFdaro
K+hM90AVD1xmU7mxy3EDPwzjK1wZTj7u0fvcAtZJztIfL+lmVpkvK8KDLQ9wCWE7
SGToOzVHYX7VazxioA9nhNne9kaixvnIUg3iowAz07J7o6EU8tfYsnHxsvjlIkBU
ai02RHnemmqJaNepfmCdyec=
-----END PRIVATE KEY-----"""
is_default = true

0 comments on commit 27503f2

Please sign in to comment.