【问题标题】:ISTIO External Auth : '503 upstream connect error or disconnect/reset before headers. reset reason: connection terminationroot' when access over HTTPSISTIO External Auth : '503 上游连接错误或在标头之前断开/重置。重置原因:通过 HTTPS 访问时连接终止根'
【发布时间】:2022-02-18 05:51:40
【问题描述】:

ISTIO 版本:1.9.4 EKS 集群版本:1.14

我们已经在我们的项目中部署了 ISTIO APP 网格。我们已经使用 istio 的文档(即https://istio.io/latest/docs/tasks/security/authorization/authz-custom/)部署了外部授权。

使用的外部授权人(如上述文档中所述):https://raw.githubusercontent.com/istio/istio/release-1.9/samples/extauthz/ext-authz.yaml

当我们使用 curl 命令从另一个 API 的 pod(即通过 http)访问任何 API 时,一切正常。外部身份验证服务被调用,所有标头都被传递到外部授权方的 v3 检查方法。以下信息通过 源、主体、目的地、标头:权限、方法、路径、接受、内容长度、用户代理、x-b3-sampled、x-b3-spanid、x-b3-traceid、x-envoy-attempt-count、 x-ext-authz、x-forwarded-client-certx-forwarded-proto、x-request-id。

但是当我们尝试通过 https 使用邮递员、浏览器或进入另一个 API 的 pod 并使用带有 https 端点的 curl 访问相同的服务时,我们会收到来自外部授权方的 v3 检查方法的拒绝响应。此外,当我们检查外部授权方的 v3 检查方法的日志时,在这种情况下没有任何标头传递给它。

下面是设置

启用 ISTIO 弹出的命名空间:foo

1. ISTIO 配置图变化

data:
  mesh: |-
    # Add the following content to define the external authorizers.
    extensionProviders:
    - name: "sample-ext-authz-grpc"
      envoyExtAuthzGrpc:
        service: "ext-authz.foo.svc.cluster.local"
        port: "9000"
    - name: "sample-ext-authz-http"
      envoyExtAuthzHttp:
        service: "ext-authz.foo.svc.cluster.local"
        port: "8000"
        includeHeadersInCheck: ["x-ext-authz"]
                    

2。外部授权人

apiVersion: v1
kind: Service
metadata:
  name: ext-authz
  namespace: foo 
  labels:
    app: ext-authz
spec:
  ports:
  - name: http
    port: 8000
    targetPort: 8000
  - name: grpc
    port: 9000
    targetPort: 9000
  selector:
    app: ext-authz
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ext-authz
  namespace: foo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ext-authz
  template:
    metadata:
      labels:
        app: ext-authz
    spec:
      containers:
      - image: docker.io/istio/ext-authz:0.6
        imagePullPolicy: IfNotPresent
        name: ext-authz
        ports:
        - containerPort: 8000
        - containerPort: 9000 

  
                    

3.启用外部授权配置

apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: ext-authz
  namespace: foo
spec:
  selector:
    matchLabels:
      app: user-api
  action: CUSTOM
  provider:
    name: sample-ext-authz-grpc
  rules:
  - to:
    - operation:
        paths: ["/user/api/*"]
                    

4. PeerAuth Chagnes

apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: mtlsauth
  namespace: foo
spec:
  mtls:
    mode: STRICT

5.目的地规则

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: default
  namespace: foo
spec:
  host: "*.samplehost.svc.cluster.local"
  trafficPolicy:
    tls:
      mode: ISTIO_MUTUAL

6.虚拟服务文件

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: sample-gateway
  namespace: foo
spec: 
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "sample.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: user-api
  namespace: foo
spec: 
  hosts:
  - "sample.com"
  gateways:
  - sample-gateway
  http:
  - match: 
    - uri:   
        prefix: /user/api/ 
    route:
    - destination:
        host: user-api
        port:
          number: 9500                 

来自入口网关的日志:

2021-07-08T11:13:33.554104Z 警告特使配置 StreamAggregatedResources gRPC 配置流已关闭:14,连接错误:desc =“传输:拨号时出错 dial tcp 172.20.0.51:15012:连接:连接被拒绝”
2021-07-08T11:13:35.420052Z info xdsproxy 连接到上游 XDS 服务器:istiod.istio-system.svc:15012
2021-07-08T11:43:24.012961Z 警告特使配置 StreamAggregatedResources gRPC 配置流已关闭:0

【问题讨论】:

  • 如果有人可以看看并帮助我了解上述配置是否有问题,那就太好了。
  • 嗨@AmolSurve,欢迎来到 Stack Overflow。如果我错了,请纠正我,您的问题是一切都适用于 HTTP 但不适用于 HTTPS?您希望它与 HTTPS 一起使用吗?
  • @PawełGrondal,非常感谢您的回复。是的,您是正确的,一切都适用于 HTTP,但不适用于 HTTPS,并希望它适用于 HTTPS。
  • 下面是来自入口网关2021-07-08T11:13:33.554104Z warning envoy config StreamAggregatedResources gRPC config stream closed: 14, connection error: desc = "transport: Error while dialing dial tcp 172.20.0.51:15012: connect: connection refused" 2021-07-08T11:13:35.420052Z info xdsproxy connected to upstream XDS server: istiod.istio-system.svc:15012 2021-07-08T11:43:24.012961Z warning envoy config StreamAggregatedResources gRPC config stream closed: 0的日志我还检查了端口15012是否打开
  • 我仍然面临这个问题。需要相同的指导。

标签: istio


【解决方案1】:

我不确定你是否面临这个问题,但如果你似乎已经强制执行 mtls 。这就是为什么在网关的以下配置中。您可能还需要打开 HTTPS api版本:networking.istio.io/v1alpha3 种类:网关 元数据: 名称:样本网关 命名空间:foo 规格: 选择器: istio:入口网关 服务器:

  • 端口: 数量:80 名称:http 协议:HTTP 主持人:
    • “sample.com”
  • 端口: 数量:443 名称:https 协议:HTTPS 主持人:
    • “sample.com”

【讨论】:

    猜你喜欢
    • 2019-12-29
    • 2020-08-11
    • 2021-06-30
    • 2021-12-22
    • 2022-11-04
    • 2019-11-18
    • 2019-04-05
    • 2020-12-04
    • 2021-11-13
    相关资源
    最近更新 更多