/
aprogrammer
/
reverse-proxy-ms-yarp
Обзор
Документация
Войти
/
aprogrammer
/
reverse-proxy-ms-yarp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/ReverseProxy.Config.Sample/appsettings.json
128 строк
7 KB
Chintan Raval
💡feat: allow for simpler override of Response header encoding of Forwarded Requests (#2254)
22 сен 2023, 18:12
Не верифицирован
22 сен 2023, 18:12
0f491bd
Код
Авторство
О чём код?
{ // Base URLs the server listens on, must be configured independently of the routes below. // Can also be configured via Kestrel/Endpoints, see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints "Urls": "http://localhost:5000;https://localhost:5001", //Sets the Logging level for ASP.NET "Logging": { "LogLevel": { "Default": "Information", // Uncomment to hide diagnostic messages from runtime and proxy // "Microsoft": "Warning", // "Yarp" : "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*", // Configuration for YARP "ReverseProxy": { // Routes tell the proxy which requests to forward "Routes": { "minimalRoute": { // Matches anything and routes it to www.example.com "ClusterId": "minimalCluster", "Match": { "Path": "{**catch-all}" } }, "allRouteProps": { // matches /download/* and routes to "allClusterProps" "ClusterId": "allClusterProps", // Name of one of the clusters "Order": 0, // Lower numbers have higher precidence, default is 0 "Authorization Policy": "Anonymous", // Name of the policy or "Default", "Anonymous" "CorsPolicy": "disable", // Name of the CorsPolicy to apply to this route or "default", "disable" "Match": { // Rules that have to be met for the route to match the request "Path": "/download/{**remainder}", // The path to match using ASP.NET syntax. "Hosts": [ "localhost", "www.aaaaa.com", "www.bbbbb.com" ], // The host names to match, unspecified is any "Methods": [ "GET", "PUT" ], // The HTTP methods that match, unspecified is all "Headers": [ // The headers to match, unspecified is any { "Name": "MyCustomHeader", // Name of the header "Values": [ "value1", "value2", "another value" ], // Matches are against any of these values "Mode": "ExactHeader", // or "HeaderPrefix", "Exists" , "Contains", "NotContains" "IsCaseSensitive": true } ], "QueryParameters": [ // The query parameters to match, unspecified is any { "Name": "MyQueryParameter", // Name of the query parameter "Values": [ "value1", "value2", "another value" ], // Matches are against any of these values "Mode": "Exact", // or "Prefix", "Exists" , "Contains", "NotContains" "IsCaseSensitive": true } ] }, "MetaData": { // List of key value pairs that can be used by custom extensions "MyName": "MyValue" }, "Transforms": [ // List of transforms. See ReverseProxy.Transforms.Sample for more details { "RequestHeader": "MyHeader", "Set": "MyValue" } ] } }, // Clusters tell the proxy where and how to forward requests "Clusters": { // Cluster with the minimum information "minimalCluster": { "Destinations": { // Specifies which back end servers requests should be routed to. "example.com": { // name is used for logging and via extensibility "Address": "http://www.example.com" // Should specify Protocol, Address/IP & Port, but not path } } }, "allClusterProps": { // Cluster with all properties "Destinations": { // Specifies which back end servers requests should be routed to. "first_destination": { // name is used for logging and via extensibility "Address": "https://dotnet.microsoft.com" // Should specify Protocol, Address/IP & Port, but not path }, "another_destination": { "Address": "https://10.20.30.40", "Health": "https://10.20.30.40:12345" // override for active health checks } }, "LoadBalancingPolicy": "PowerOfTwoChoices", // Alternatively "First", "Random", "RoundRobin", "LeastRequests" "SessionAffinity": { // Ensures subsequent requests from a client go to the same destination server "Enabled": true, // Defaults to 'false' "Policy": "HashCookie", // Default, alternatively "Cookie" or "CustomHeader" "FailurePolicy": "Redistribute", // default, alternatively "Return503Error" "AffinityKeyName": "MySessionCookieName" // Required, no default }, "HealthCheck": { // Ways to determine which destinations should be filtered out due to unhealthy state "Active": { // Makes API calls to validate the health of each destination "Enabled": "true", "Interval": "00:00:10", // How often to query for health data "Timeout": "00:00:10", // Timeout for the health check request/response "Policy": "ConsecutiveFailures", // Or other custom policy that has been registered "Path": "/favicon.ico" // API endpoint to query for health state. Looks for 2XX response codes to indicate healthy state // Typically something like "/api/health" but used favicon to enable sample to run }, "Passive": { // Disables destinations based on HTTP response codes for proxy requests "Enabled": true, // Defaults to false "Policy": "TransportFailureRate", // Or other custom policy that has been registered "ReactivationPeriod": "00:00:10" // how long before the destination is re-enabled } }, "HttpClient": { // Configuration of HttpClient instance used to contact destinations "SSLProtocols": "Tls13", "DangerousAcceptAnyServerCertificate": true, // Disables destination cert validation "MaxConnectionsPerServer": 1024, // Destination server can further limit this number "EnableMultipleHttp2Connections": true, "RequestHeaderEncoding": "Latin1", // How to interpret non ASCII characters in proxied request's header values "ResponseHeaderEncoding": "Latin1" // How to interpret non ASCII characters in proxied request's response header values }, "HttpRequest": { // Options for sending request to destination "Timeout": "00:02:00", // Timeout for the HttpRequest "Version": "2", // Http Version that should be tried first "VersionPolicy": "RequestVersionOrLower" // Policy for which other versions can be be used }, "MetaData": { // Custom Key/value pairs for extensibility "TransportFailureRateHealthPolicy.RateLimit": "0.5", // Used by Passive health policy "MyKey": "MyValue" } } } } }