Simplified proxy example, no more proxy.conf file.

Added forwarding case based on server name.
This commit is contained in:
2019-01-24 11:19:05 +01:00
parent 65525aa112
commit 5ff361af54
4 changed files with 65 additions and 68 deletions

View File

@@ -2,5 +2,17 @@ Proxy example
=============
Via the `wsf_proxy` library, it is possible to implement a simple reverse proxy service.
Note: you need to edit the `proxy.conf` file to use proper remote service.
(You can use for instance any of the EWF examples as remote server, or also existing public server).
This example forwards request based on server name, or location as described below:
- if server name is `foo`, forwards to `http://localhost:8080/foo`
- if server name is `bar`, forwards to `http://localhost:8080/bar`
- if path starts with "/search/", forwards to `http://www.google.com/search?q=`
For instance:
- http://foo/a/test -> http://localhost:8080/foo/a/test
- http://localhost:9090/search/eiffel -> http://www.google.com/search?q=eiffel
Notes:
- look at `{APPLICATION_EXECUTION}.execute` for the implementation.
- the `send_proxy_response` implements a general forwarding, but for more advanced need, this could be customized per forwarding. For instance, a specific forwarding, may need the X-Forwarded headers, or to keep the `Host` from the client, ...