Awesome
ProxyKit Recipes
Recipes are code samples that help you create proxy solutions for your needs. If you have any ideas for a recipe, or can spot any improvements to the ones below, please send a pull request! Recipes that stand test of time may be promoted to an out-of-the-box feature in a future version of ProxyKit.
<!-- TOC depthFrom:2 -->- 1. Simple Forwarding
- 2. Proxy Paths
- 3. Claims Based Tenant Routing
- 4. Authentication offloading with Identity Server
- 5. Weighted Round Robin Load Balancing
- 6. In-memory Testing
- 7. Customise Upstream Requests
- 8. Customise Upstream Responses
- 9. Consul Service Discovery
- 10. Copy X-Forwarded Headers
- 11. Caching Upstream Responses with CacheCow
- 12. Conditional Proxying
- 13. Client Certificate
- 14. Source IP Blocking
- 15. WebSockets
- 16. SignalR
- 17. SignalR with Path
- 18. Automatic Decompression
Recipes are code samples that help you create proxy solutions for your needs. If you have any ideas for a recipe, or can spot any improvements to the ones below, please send a pull request! Recipes that stand test of time may be promoted to an out-of-the-box feature in a future version of ProxyKit.
1. Simple Forwarding
Forward request to a single upstream host.
2. Proxy Paths
Hosting multiple proxies on separate paths.
3. Claims Based Tenant Routing
Routing to a specific upstream host based on a TenantId
claim for an
authenticated user.
4. Authentication offloading with Identity Server
Using IdentityServer to handle authentication before forwarding to upstream host.
5. Weighted Round Robin Load Balancing
Weighted Round Robin load balancing to two upstream hosts.
6. In-memory Testing
Testing behaviour or your ASP.NET Core application by running two instances behind round robin proxy. Really useful if your application has eventually consistent aspects.
7. Customise Upstream Requests
Customise the upstream request by adding a header.
Recipes/07_CustomiseUpstreamRequest.cs
8. Customise Upstream Responses
Customise the upstream response by removing a header.
Recipes/08_CustomiseUpstreamResponse.cs
9. Consul Service Discovery
Service discovery for an upstream host using Consul.
Recipes/09_ConsulServiceDisco.cs
10. Copy X-Forwarded Headers
Copies X-Forwarded-For
, X-Forwarded-Host
, X-Forwarded-Proto
and
X-Forwarded-PathBase
headers from the incoming request. Typically only done
when the proxy is in a chain of known proxies. Is it NOT recommended that you
blindly accept these headers from the public Internet.
11. Caching Upstream Responses with CacheCow
Using CacheCow.Client to cache responses from upstream servers using standard HTTP caching headers.
Recipes/11_CachingWithCacheCow.cs
12. Conditional Proxying
Using app.UseWhen()
to conditionally forward the request based on asserting a
value on HttpContext
.
Recipes/12_ConditionalProxying.cs
13. Client Certificate
Using a client certificate in requests to upstream hosts.
Recipes/13_ClientCertificate.cs
14. Source IP Blocking
Block requests from sources whose IP addresses is not allowed.
Recipes/14_SourceIPBlocking.cs
15. WebSockets
How to proxy WebSocket connections.
16. SignalR
Proxying for SignalR whose protocol requires both HTTP and WebSocket forwarding to upstream hosts.
17. SignalR with Path
Proxying for SignalR on a specific path.
18. Automatic Decompression
Automatic decompression of responses from upstream hosts allowing response body manipulation.