A reverse proxy in rust which is built on top of hyper. Below are current features:
- Multi downstreams per request path
- Retries with next downstreams
- Automatically checks if downstream is coming back
- Supports https/http to downstreams
- Caches static files (js/css).
- Supports gzip and brotli compression based on request header for static files
- Requests logs (log4rs)
Mininum prequisite is config.yaml; you will to put configuration to '/usr/local/bin/hupe/config.yaml' in the docker container. Optionally, we can mount static files too (based on configuration)
configuration:
listening_port: 80
enable_retry: true
enable_log: true
request_paths:
- down_streams:
- https://www.example.com
- https://api.localhost2
map_to: /another
uri_path: /another/*
- down_streams:
- http://example.com
- http://api.localhost1
map_to: /
uri_path: /*
Note: above configurations mean:
- Start hupe and listen on port 80
- Enable both retry and log
- Any request path starts with '/another' will forward to https://example.com/another or https://api.localhost2/another
- Other requests will forward to http://example.com or http://api.localhost1
- We are using regex for uri_path and ordering request_paths' priority from top to bottom
- Image from docker hup
```
docker run -p 80:80 -v config.yaml:/usr/local/bin/hupe/config.yaml -v assets:/usr/local/bin/hupe/assets p3go/hupe:v.0.1
```
- Build and run docker
```
docker build . -t hupe
docker run -p 80:80 -v config.yaml:/usr/local/bin/hupe/config.yaml -v assets:/usr/local/bin/hupe/assets hupe
```
configuration:
listening_port: 80
enable_retry: true
enable_log: true
request_paths:
- down_streams:
- http://example.com
- http://api.localhost1
map_to: /
uri_path: /*
- down_streams:
- https://www.example.com
- http://api.localhost2
map_to: /another
uri_path: /another/*
request_files:
- uri_path: /assets/js
map_to: /usr/local/bin/hupe/assets/js
- uri_path: /assets/css
map_to: /usr/local/bin/hupe/assets/css
Note: this time we forward any request starting with '/assets/js' to directory '/usr/local/bin/hupe/assets/js', for example, 'http://localhost/assets/js/index.js', we map (or read) to file system: '/usr/local/bin/hupe/assets/js/index.js'