Skip to content

Commit 10874f4

Browse files
authored
Enhance HTTPserver to support nginx-like header vars and build-in backend pool (#1497)
* HTTPServer: Support set headers with nginx-like vars * HTTPServer: test nginx-like vars * HTTPServer: Implement backendPool with generating proxy pipeline * Support labels for metadata of object * Add httpserver owner label and fix unittest * Fix Validate of validator spec * Use cluster to manage generated pipeline instead traffic controller * Forbid updating generated objects * Update quick start to adopt backend pool in HTTPServer * Doc: Add nginx header vars * Doc: Update header size * Fix unit tests * Fix TestPathValidate
1 parent 037ef85 commit 10874f4

File tree

17 files changed

+1470
-97
lines changed

17 files changed

+1470
-97
lines changed

docs/01.Getting-Started/1.1.Quick-Start.md

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
The basic usage of Easegress is to quickly set up a proxy for the backend servers.
44

5-
### Launch Easegress
5+
## Launch Easegress
66

77
Easegress can be installed from pre-built binaries or from source. For details, see [Install](1.2.Install.md).
88

9-
109
Then we can execute the server:
1110

1211
```bash
@@ -17,7 +16,7 @@ $ easegress-server
1716

1817
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.
1918

20-
After launching successfully, we could check the status of the one-node cluster.
19+
After launching successfully, we could check the status of the one-node cluster.
2120

2221
```bash
2322
$ egctl get member
@@ -27,40 +26,72 @@ $ egctl describe member
2726
...
2827
```
2928

30-
### Reverse Proxy
29+
## Reverse Proxy
3130

3231
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:
3332

3433
```bash
35-
$ egctl create httpproxy demo --port 10080 \
34+
$ egctl create httpproxy demo --port 10080 \
3635
--rule="/pipeline=http://127.0.0.1:9095,http://127.0.0.1:9096" \
3736
--rule="/prefix*=http://127.0.0.1:9097"
3837
```
3938

4039
Then try it:
40+
4141
```bash
42-
$ curl -v 127.0.0.1:10080/pipeline
42+
curl -v 127.0.0.1:10080/pipeline
4343
```
4444

4545
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.
4646

4747
```bash
48-
$ curl -v 127.0.0.1:10080/prefix/123
48+
curl -v 127.0.0.1:10080/prefix/123
4949
```
50-
The request will be forwarded to `127.0.0.1:9097/prefix/123`.
5150

51+
The request will be forwarded to `127.0.0.1:9097/prefix/123`.
52+
53+
## YAML Configuration
5254

53-
### YAML Configuration
55+
The `egctl create httpproxy` command is convenient, but for production use, you'll want more control. Easegress uses two main resources: **HTTPServer** (handles incoming requests) and **Pipeline** (processes and routes requests).
5456

55-
The `egctl create httpproxy` command mentioned above is actually syntactic sugar; it creates two Easegress resources under the hood: `HTTPServer` and `Pipeline`.
57+
### Method 1: HTTPServer with Built-in Backend Pool
5658

57-
Now let's create them using yaml files:
59+
This approach automatically creates pipelines for you:
60+
61+
```bash
62+
$ echo 'kind: HTTPServer
63+
name: demo-backend-pool
64+
port: 10080
65+
https: false
66+
rules:
67+
- paths:
68+
- pathPrefix: /demo0
69+
backendPool:
70+
loadBalance:
71+
policy: roundRobin
72+
servers:
73+
- url: http://127.0.0.1:9091
74+
- url: http://127.0.0.1:9092
75+
- pathPrefix: /demo1
76+
backendPool:
77+
loadBalance:
78+
policy: roundRobin
79+
servers:
80+
- url: http://127.0.0.1:9093
81+
- url: http://127.0.0.1:9094' | egctl create -f -
82+
```
83+
84+
It will generate one pipeline for each backendPool. For example, `demo-backend-pool` generates pipeline`GENERATED-demo-backend-pool-0-0` and `GENERATED-demo-backend-pool-0-1` which couldn't be updated or deleted via `egctl` (User APIs).
85+
86+
### Method 2: HTTPServer with Separate Pipelines
87+
88+
Create HTTPServer:
5889

5990
```bash
6091
$ echo '
6192
kind: HTTPServer
62-
name: demo
63-
port: 10080
93+
name: demo-backend
94+
port: 10081
6495
https: false
6596
rules:
6697
- paths:
@@ -69,7 +100,8 @@ rules:
69100
- pathPrefix: /prefix
70101
backend: demo-1 ' | egctl create -f -
71102
```
72-
More details about [HTTPServer](../02.Tutorials/2.2.HTTP-Proxy-Usage.md).
103+
104+
Create the Pipelines:
73105

74106
```bash
75107
$ echo '
@@ -98,7 +130,7 @@ filters:
98130
- servers:
99131
- url: http://127.0.0.1:9097' | egctl create -f -
100132
```
133+
101134
More details about [Pipeline](../02.Tutorials/2.3.Pipeline-Explained.md).
102135

103136
You can also modify, update, or delete these resources using `egctl`; for more details, refer to the [egctl usage](../02.Tutorials/2.1.egctl-Usage.md) guide.
104-

0 commit comments

Comments
 (0)