The reverse proxy is the common middleware that is accessed by clients, forwards them to backend servers. The reverse proxy is a very core role played by Easegress.
Easegress integrates many features as a reverse proxy with easy configuration.
- Offload SSL/TLS layer
- Hot-updated routing without losing requests
- Intercept invalid requests (according to IP, metadata of requests, credential verification, etc)
- Adapting requests to satisfy requirements of backend servers
- Bring more resilience for backend servers (rate limiting, time limiting, circuit breaker, retrying)
- Load balance for backend servers (static addresses, or integration with service registry)
- Compression and Caching for response
The filter Proxy
is the filter to fire requests to backend servers. It contains servers group under load balance, whose policy support roundRobin
, random
, weightedRandom
, ipHash
, headerHash
.
name: pipeline-reverse-proxy
kind: Pipeline
flow:
- filter: proxy
filters:
- name: proxy
kind: Proxy
pools:
- servers:
- url: https://127.0.0.1:9095
- url: https://127.0.0.1:9096
- url: https://127.0.0.1:9097
loadBalance:
policy: roundRobin
Sometimes backend applications can't adapt to quick changes of requirements of traffic. Easegress could be an adaptor between new traffic and old applications. There are 2 phases of adaption in reverse proxy: request adaption, response adaption. RequestAdaptor
supports the adaption of a method, path, header, and body. ResponseAdaptor
supports the adaption of header and body. As you can see, the flow in spec plays a critical role.
name: pipeline-reverse-proxy
kind: Pipeline
flow:
- filter: requestAdaptor
- fitter: proxy
- filter: responseAdaptor
filters:
- name: requestAdaptor
kind: RequestAdaptor
host: easegress.megaease.com
method: POST
path:
addPrefix: /apis/v2
header:
set:
X-Api-Version: v2
- name: responseAdaptor
kind: ResponseAdaptor
header:
set:
Server: Easegress v1.0.0
add:
X-Easegress-Pipeline: pipeline-reverse-proxy
- name: proxy
kind: Proxy
# ...
For the full YAML, see here
name: pipeline-reverse-proxy
kind: Pipeline
flow:
- filter: requestAdaptor
- fitter: proxy
- filter: responseAdaptor
filters:
- name: requestAdaptor
kind: RequestAdaptor
host: easegress.megaease.com
method: POST
path:
addPrefix: /apis/v2
header:
set:
X-Api-Version: v2
- name: responseAdaptor
kind: ResponseAdaptor
header:
set:
Server: Easegress v1.0.0
add:
X-Easegress-Pipeline: pipeline-reverse-proxy
- name: proxy
kind: Proxy
pools:
- servers:
- url: https://127.0.0.1:9095
- url: https://127.0.0.1:9096
- url: https://127.0.0.1:9097
loadBalance:
policy: roundRobin