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
- 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.
Forward request to a single upstream host.
Hosting multiple proxies on separate paths.
Routing to a specific upstream host based on a TenantId
claim for an
authenticated user.
Using IdentityServer to handle authentication before forwarding to upstream host.
Weighted Round Robin load balancing to two upstream hosts.
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.
Customise the upstream request by adding a header.
Recipes/07_CustomiseUpstreamRequest.cs
Customise the upstream response by removing a header.
Recipes/08_CustomiseUpstreamResponse.cs
Service discovery for an upstream host using Consul.
Recipes/09_ConsulServiceDisco.cs
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.
Using CacheCow.Client to cache responses from upstream servers using standard HTTP caching headers.
Recipes/11_CachingWithCacheCow.cs
Using app.UseWhen()
to conditionally forward the request based on asserting a
value on HttpContext
.
Recipes/12_ConditionalProxying.cs
Using a client certificate in requests to upstream hosts.
Recipes/13_ClientCertificate.cs
Block requests from sources whose IP addresses is not allowed.
Recipes/14_SourceIPBlocking.cs
How to proxy WebSocket connections.
Proxying for SignalR whose protocol requires both HTTP and WebSocket forwarding to upstream hosts.
Proxying for SignalR on a specific path.
Automatic decompression of responses from upstream hosts allowing response body manipulation.