You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/README.md
+19-11Lines changed: 19 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ This crate provides a couple of example using [ngx](https://crates.io/crates/ngx
16
16
-[awssig.rs](./awssig.rs) - An example of NGINX dynamic module that can sign GET request using AWS Signature v4.
17
17
-[curl](./curl.rs) - An example of the Access Phase NGINX dynamic module that blocks HTTP requests if `user-agent` header starts with `curl`.
18
18
-[httporigdst](./httporigdst.rs) - A dynamic module recovers the original IP address and port number of the destination packet.
19
+
-[upstream](./upstream.rs) - A dynamic module demonstrating the setup code to write an upstream filter or load balancer.
19
20
20
21
To build all these examples simply run:
21
22
@@ -168,20 +169,27 @@ This module was converted from https://github.com/gabihodoroaga/nginx-upstream-m
168
169
load_module "modules/upstream.so"
169
170
170
171
http {
171
-
upstream backend {
172
-
server localhost:8081;
172
+
upstream backend {
173
+
server localhost:15501;
174
+
custom 32;
175
+
}
176
+
177
+
server {
178
+
listen 15500;
179
+
server_name _;
173
180
174
-
custom 32;
175
-
}
181
+
location / {
182
+
proxy_pass http://backend;
183
+
}
184
+
}
176
185
177
-
server {
178
-
listen 8080;
179
-
server_name _;
186
+
server {
187
+
listen 15501;
180
188
181
-
location / {
182
-
proxy_pass http://backend;
189
+
location / {
190
+
return 418;
191
+
}
183
192
}
184
-
}
185
193
}
186
194
```
187
195
@@ -215,4 +223,4 @@ http {
215
223
nginx -t && nginx -s reload
216
224
```
217
225
218
-
7. Test with `curl`. Traffic should pass to your listener on port 8081 (this could be another NGINX server for example). With debug logging enabled you should notice the "custom" log messages (see the source code for log examples).
226
+
7. Test with `curl`. Traffic should pass to your listener on port 8081 (this could be another NGINX server for example). With debug logging enabled you should notice the upstream log messages (see the source code for log examples, prefixed with "CUSTOM UPSTREAM").
0 commit comments