Skip to content

Commit

Permalink
docs: add proxy upstream example
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Nov 17, 2024
1 parent 46b17e7 commit e7fbacd
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
23 changes: 23 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# examples


## Static-Server

```bash
cargo run -- -c=~/github/pingap/examples/static-serve.toml --admin=127.0.0.1:3018
```

```bash
curl http://127.0.0.1:3000/ -v
```

## Proxy-Upstream

Upstream features:

- Support comresssion: zstd, br, gzip
- Static cache: public, max-age=31536000

```bash
cargo run -- -c=~/github/pingap/examples/proxy-upstream.toml --admin=127.0.0.1:3018
```
29 changes: 29 additions & 0 deletions examples/proxy-upstream.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[basic]
cache_directory = "~/tmp/cache"
log_level = "INFO"

[locations.charts]
path = "/"
plugins = [
"pingap:acceptEncodingAdjustment",
"chartsCache",
]
upstream = "charts"

[plugins.chartsCache]
category = "cache"
headers = ["Accept-Encoding"]
max_ttl = "1h"
namespace = "charts"
step = "request"

[servers.charts]
addr = "127.0.0.1:3000"
locations = ["charts"]

[upstreams.charts]
addrs = [
"127.0.0.1:5000",
"127.0.0.1:5001",
]
health_check = "http://charts/ping"
17 changes: 2 additions & 15 deletions examples/static-serve.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
[locations.staticServe]
plugins = [
"staticAcceptEncoding",
"staticCompression",
"pingap:acceptEncodingAdjustment",
"pingap:compression",
"staticServe",
]

[plugins.staticAcceptEncoding]
category = "accept_encoding"
encodings = "zstd, br, gzip"
only_one_encoding = true
step = "request"

[plugins.staticCompression]
br_level = 9
category = "compression"
gzip_level = 9
step = "request"
zstd_level = 9

[plugins.staticServe]
category = "directory"
path = "~/github/pingap/dist"
Expand Down

0 comments on commit e7fbacd

Please sign in to comment.