Quick Start
The basic usage of Easegress is to quickly set up a proxy for the backend servers.
Launch Easegress
Easegress can be installed from pre-built binaries or from source. For details, see Install.
Then we can execute the server:
$ easegress-server
2023-09-06T15:12:49.256+08:00 INFO cluster/config.go:110 config: advertise-client-urls: ...
...
By default, Easegress opens ports 2379, 2380, and 2381; however, you can modify these settings along with other arguments either in the configuration file or via command-line arguments. For a complete list of arguments, please refer to the easegress-server --help
command.
After launching successfully, we could check the status of the one-node cluster.
$ egctl get member
...
$ egctl describe member
...
Reverse Proxy
Assuming you have two backend HTTP services running at 127.0.0.1:9095
and 127.0.0.1:9096
, you can initiate an HTTP proxy from port 10080 to these backends using the following command:
$ egctl create httpproxy demo --port 10080 \
--rule="/pipeline=http://127.0.0.1:9095,http://127.0.0.1:9096"
Then try it:
$ curl -v 127.0.0.1:10080/pipeline
The request will be forwarded to either 127.0.0.1:9095/pipeline
or 127.0.0.1:9096/pipeline
, utilizing a round-robin load-balancing policy.
YAML Configuration
The egctl create httpproxy
command mentioned above is actually syntactic sugar; it creates two Easegress resources under the hood: HTTPServer
and Pipeline
.
Now let’s create them using yaml files:
$ echo '
kind: HTTPServer
name: demo
port: 10080
https: false
rules:
- paths:
- path: /pipeline
backend: demo-0' | egctl create -f -
More details about HTTPServer.
$ echo '
name: demo-0
kind: Pipeline
flow:
- filter: proxy
filters:
- name: proxy
kind: Proxy
pools:
- servers:
- url: http://127.0.0.1:9095
- url: http://127.0.0.1:9096
loadBalance:
policy: roundRobin' | egctl create -f -
More details about Pipeline.
You can also modify, update, or delete these resources using egctl
; for more details, refer to the egctl usage guide.