1. 程式人生 > 其它 >reverse-proxy config-files

reverse-proxy config-files

{
  // 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"
        }
      }
    }
  }
}

配置檔案 (microsoft.github.io)