kubernetes Istio -将请求重定向到外部URL

flseospp  于 2023-03-22  发布在  Kubernetes
关注(0)|答案(1)|浏览(127)

我正在尝试使用istio在Kubernetes集群中设置代理服务。我已经创建了两个不同的域。如果域是foo.com,则应该重定向到外部URL,否则应该路由到应用服务器。我已经使用虚拟服务和服务条目配置了这个。但是当我点击foo.com时,它跳过了Authorization头。我需要一个Authorization头来处理请求。有什么办法可以解决这个问题吗?提前感谢。
VirtualService.yaml

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: external-svc-https
spec:
  hosts:
  - foo.com
  location: MESH_EXTERNAL
  ports:
  - number: 443
    name: https
    protocol: TLS
  resolution: DNS
---
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
  name: redirect
  namespace: default
  labels:
    app: foo
    env: staging
spec:
  hosts:
    - foo.com
  gateways:
    - istio-system/gateway
  http:
    - match:
        - uri:
            prefix: /
      redirect:
        authority: bar.com
xxhby3vn

xxhby3vn1#

如果在foo.com域被命中时重定向

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: github
spec:
  hosts:
  - "raw.githubusercontent.com"
  location: MESH_EXTERNAL
  ports:
  - number: 443
    name: https
    protocol: TLS
  resolution: DNS

以及

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: webserver
spec:
  hosts:
  - foo.com
  http:
  - match:
    - uri:
        regex: ".*"
    rewrite:
      uri: "/mcasperson/NodejsProxy/master/externalservice1.txt"
      authority: raw.githubusercontent.com
    route:
    - destination:
        host: raw.githubusercontent.com
        port:
          number: 443

规则

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: github
spec:
  host: "raw.githubusercontent.com"
  trafficPolicy:
    tls:
      mode: SIMPLE

阅读更多信息:https://octopus.com/blog/istio/istio-serviceentry

相关问题