【问题标题】:istio routing http to https upstream causes causes 302istio 将 http 路由到 https 上游原因导致 302
【发布时间】:2021-07-02 04:31:59
【问题描述】:

我的入口网关位于 http 端口 80 并路由到 https 目标。

使用以下配置

http://ingress-gateway.example.com/zzz

它给出302 并且网址更改为https

https://my-site.example.com/products

为什么是302,我错过了什么?

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port: # Note: I am entering using this port
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
  - port: # Note: I am NOT entering using this port
      number: 443
      name: https
      protocol: HTTPS
    hosts:
    - "*"
    tls:
      credentialName: my-credential

---
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: apps-domain
spec:
  hosts:
  - my-site.example.com
  ports:
  - number: 443
    name: https-my-site
    protocol: HTTPS
  resolution: DNS
  location: MESH_EXTERNAL

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my
spec:
  hosts:
  - "*"
  gateways:
  - my-gateway
  http:
- match:
    - uri:
        prefix: /zzz
    rewrite:
      uri: /products
    route:
    - destination:
        port:
          number: 443
        host: my-site.example.com

---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: my-https-backend
spec: 
  host: my-site.example.com
  trafficPolicy:
    tls:
      mode: SIMPLE
      sni: my-site.example.com

【问题讨论】:

    标签: kubernetes-ingress istio


    【解决方案1】:

    你有一个指向 443 端口的重写规则

    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: my
    spec:
      hosts:
      - "*"
      gateways:
      - my-gateway
      http:
    - match:
        - uri:
            prefix: /zzz
        rewrite:
          uri: /products
        route:
        - destination:
            port:
              number: 443 # here
            host: my-site.example.com
    
    

    【讨论】:

    • 所以我应该删除 rewrite: 吗?那我怎么打my-site.example.com/product
    • @WytrzymałyWiktor 它不适用于我想要做的事情,基本上是作为 HTTP 输入并代理到 HTTPS 端点而不生成重定向。任何典型的 API 网关都可以做到这一点。
    • 将路由目的地的端口号改为80。它应该可以工作。
    猜你喜欢
    • 2011-07-22
    • 1970-01-01
    • 2019-09-01
    • 2014-09-08
    • 2019-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    相关资源
    最近更新 更多