无法理解为什么 API Gateway 会在主机名前添加“backend-cluster”前缀。请求中网关的日志如下所示:
{
httpRequest: {
latency: "0.113s"
protocol: "HTTP/1.1"
remoteIp: "5.20.198.209"
requestMethod: "GET"
requestUrl: "https://XXX.nw.gateway.dev/organizations/XXXXXXXXX/export?period=0"
responseSize: "221"
status: 503
userAgent: "PostmanRuntime/7.28.4"
}
insertId: "5cf296ad774f8088eeb7ed100ecc4498-1@a2"
jsonPayload: {
api: "//apigateway.googleapis.com/projects/XXXXXXX/locations/global/apis/eu-dev-XXX-api"
apiConfig: "//apigateway.googleapis.com/projects/XXXXXXXX/locations/global/apis/eu-dev-XXX-api/configs/config"
apiKey: "XXXXXXXXXXXXXXXXX"
apiMethod: "1.eu_dev_XXX_api_XXXXXXXXXXX_apigateway_XXX_dev_XXXXXXX_cloud_goog.GetExport"
backendRequest: {
duration: "0ms"
hostname: "**backend-cluster-**dev.equipment.example.com:443"
path: "/api/v1/XXXXXXX/organizations/XXXXXXXXXX/export?period=0"
}
consumerNumber: "XXXXXX"
responseDetails: "upstream_reset_before_response_started{connection_failure,TLS_error:_268435581:SSL_routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED}"
}
logName: "projects/XXXXXXX/logs/apigateway.googleapis.com%2Frequests"
receiveTimestamp: "2021-10-25T08:48:03.222779242Z"
resource: {
labels: {
gateway_id: "XXXXXXXX"
location: "europe-west2"
resource_container: "projects/XXXXXX"
}
type: "apigateway.googleapis.com/Gateway"
}
timestamp: "2021-10-25T08:47:51.184895263Z"
}
网关配置很简单:
# openapi2-run.yaml
swagger: '2.0'
info:
title: Export API
description: This API gateway is used to access export API functionality
version: 1.0.0
schemes:
- https
produces:
- application/json
securityDefinitions:
api_key_header:
type: apiKey
name: x-api-key
in: header
paths:
/organizations/{org_id}/export:
get:
summary: Organisation export API endpoint
operationId: getExport
x-google-backend:
address: **https://dev.equipment.example.com/api/v1/XXXXXXXX**
protocol: http/1.1
path_translation: APPEND_PATH_TO_ADDRESS
parameters:
- in: "path"
name: "org_id"
description: "The organization identifier"
required: true
type: "string"
security:
- api_key_header: []
responses:
'200':
description: A successful response
schema:
type: object
根据想法,重定向应该转到https://dev.equipment.example.com/api/v1/XXXXXXXX/organizations/XXXXXXXXXX/export?period=0而是转到https://backend-cluster-dev.equipment .example.com/api/v1/XXXXXXXX/organizations/XXXXXXXXXX/export?period=0当然它失败了。
你有什么想法为什么会发生?
先感谢您!