{
// Base URLs the server listens on, must be configured independently of the routes below
// 服务器侦听的基本URL必须独立于下面的路由进行配置
//"Urls": "http://localhost:5000;https://localhost:5001",
"Logging": {
"LogLevel": {
"Default": "Information",
// Uncomment to hide diagnostic messages from runtime and proxy
// 取消对运行时和代理隐藏诊断消息的注释
// "Microsoft": "Warning",
// "Yarp" : "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ReverseProxy": {
// Routes tell the proxy which requests to forward
//取消对运行时和代理隐藏诊断消息的注释
"Routes": {
"minimumroute": {
// Matches anything and routes it to www.example.com
//匹配任何内容并将其路由到www.example。通用域名格式
"ClusterId": "minimumcluster",
"Match": {
"Path": "{**catch-all}"
}
},
// 匹配/something/*并路由到“allclusterprops”
"allrouteprops": {
// matches /something/* and routes to "allclusterprops"
//其中一个集群的名称
"ClusterId": "allclusterprops", // Name of one of the clusters
//数字越小,优先级越高
"Order": 100, // Lower numbers have higher precedence
//"Anonymous" 策略名称或“默认”、“匿名”
"Authorization Policy": "Anonymous", // Name of the policy or "Default",
//要应用于此路由的公司名称或“默认”、“禁用”
"CorsPolicy": "Default", // Name of the CorsPolicy to apply to this route or "Default", "Disable"
"Match": {
//要使用ASP进行匹配的路径。NET语法。
"Path": "/something/{**remainder}", // The path to match using ASP.NET syntax.
//要匹配的主机名(未指定)为any
"Hosts": [ "www.aaaaa.com", "www.bbbbb.com" ], // The host names to match, unspecified is any
//匹配的HTTP方法,USSpecified就是全部
"Methods": [ "GET", "PUT" ], // The HTTP methods that match, uspecified 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
//或“HeaderPrefix”、“Exists”、“Contains”、“NotContains”
"Mode": "ExactHeader", // or "HeaderPrefix", "Exists" , "Contains", "NotContains"
"IsCaseSensitive": true
}
],
//要匹配的查询参数(未指定)为any
"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文章
"Transforms": [ // List of transforms. See the Transforms article for more details
{
"RequestHeader": "MyHeader",
"Set": "MyValue"
}
]
}
},
//集群告诉代理在哪里以及如何转发请求
// Clusters tell the proxy where and how to forward requests
"Clusters": {
"minimumcluster": {
"Destinations": {
"example.com": {
"Address": "https://www.baidu.com"
}
}
},
"allclusterprops": {
"Destinations": {
"first_destination": {
"Address": "https://contoso.com"
},
"another_destination": {
"Address": "https://10.20.30.40",
//主动健康检查的覆盖
"Health": "https://10.20.30.40:12345/test" // override for active health checks
}
},
//或者“第一字母顺序”、“随机”、“循环”、“最少任务”
"LoadBalancingPolicy": "PowerOfTwoChoices", // Alternatively "FirstAlphabetical", "Random", "RoundRobin", "LeastRequests"
"SessionAffinity": {
"Enabled": true, // Defaults to 'false'
"Policy": "Cookie", // Default, alternatively "CustomHeader"
"FailurePolicy": "Redistribute", // default, Alternatively "Return503Error"
"Settings": {
"CustomHeaderName": "MySessionHeaderName" // Defaults to 'X-Yarp-Proxy-Affinity`
}
},
"HealthCheck": {
"Active": { // Makes API calls to validate the health.
"Enabled": "true",
"Interval": "00:00:10",
"Timeout": "00:00:10",
"Policy": "ConsecutiveFailures",
"Path": "/api/health" // API endpoint to query for health state
},
"Passive": { // Disables destinations based on HTTP response codes
"Enabled": true, // Defaults to false
"Policy": "TransportFailureRateHealthPolicy", // Required
"ReactivationPeriod": "00:00:10" // 10s
}
},
//用于联系目的地的HttpClient实例的配置
"HttpClient": { // Configuration of HttpClient instance used to contact destinations
"SSLProtocols": "Tls13",
"DangerousAcceptAnyServerCertificate": false,
"MaxConnectionsPerServer": 1024,
"EnableMultipleHttp2Connections": true,
//如何解释标题值中的非ASCII字符
"RequestHeaderEncoding": "Latin1" // How to interpret non ASCII characters in header values
},
//向目的地发送请求的选项
"HttpRequest": { // Options for sending request to destination
"ActivityTimeout": "00:02:00",
"Version": "2",
"VersionPolicy": "RequestVersionOrLower",
"AllowResponseBuffering": "false"
},
//自定义键值对
"MetaData": { // Custom Key value pairs
"TransportFailureRateHealthPolicy.RateLimit": "0.5", // Used by Passive health policy
"MyKey": "MyValue"
}
}
}
}
}