当前位置: 首页 > 知识库问答 >
问题:

您正在对Kubernetes中启用SSL的服务器端口说纯HTTP

林鸿飞
2023-03-14

我的网关文件为

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway-secure
  namespace: myapp
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
      privateKey: /etc/istio/ingressgateway-certs/tls.key
      #caCertificates: /etc/istio/ingressgateway-ca-certs/kbundle.crt
    hosts:
    - "*"

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-gateway-service-secure
  namespace:myapp
spec:
  hosts:
  - "sub.domaincom"
  gateways:
  - my-gateway-secure
  http:
  - route:
    - destination:
        host: my-mono
        port:
          number: 443
          protocol: TCP

apiVersion: v1
kind: Service
metadata:
  name: my-mono
  namespace: myapp
  labels:
    tier: backend
spec:
  selector:
    app: my-mono
    tier: backend
  ports:
    - port: 443
      name: https
      protocol: TCP

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-mono
  namespace: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-mono
  template:
    metadata:
      labels:
        app: my-mono
    spec:
      containers:
      - name: my-mono
        image: myapacheimage
        imagePullPolicy: Never   
        ports:  
        - containerPort: 443
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
Apache/2.4.38 (Debian) Server at 10.0.159.77 Port 443

我可以确认apache只侦听443,并且配置正确

共有1个答案

董庆
2023-03-14

您的配置在istio网关上使用TLS端接。因此进入istio入口的HTTPS流量在到达服务endpoint之前被解密为普通HTTP流量。

要解决此问题,您需要配置对https服务的https入口访问,即配置入口网关对传入请求执行SNI通过,而不是TLS终止。

您可以在这里的istio文档指南中找到没有TLS终止的入口网关示例。

您的网关虚拟服务应该如下所示:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway-secure
  namespace: myapp
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: PASSTHROUGH
    hosts:
    - "*"

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-gateway-service-secure
  namespace:myapp
spec:
  hosts:
  - "sub.domaincom"
  gateways:
  - my-gateway-secure
  tls:
  - match:
    - port: 443
      sni_hosts:
      - "sub.domaincom"
    route:
    - destination:
        host: my-mono
        port:
          number: 443

希望有帮助。

 类似资料:
  • 具有TLS配置的典型入口如下所示: 发现GLBC正在讨论为GCE入口启用HTTPS后端。文件摘录: 后端HTTPS 对于负载均衡器和Kubernetes服务之间的加密通信,您需要将服务的端口装饰为预期的HTTPS。有一个alpha服务注释用于指定每个服务端口的预期协议。当将协议视为HTTPS时,入口控制器将使用带有HTTPS健康检查的HTTPS后端服务组装GCP L7负载均衡器。“ 不清楚负载均衡

  • gRPC新手,找不到任何关于如何在服务器端启用SSL的例子。我使用openssl生成了一个密钥对,但是它报错说私钥无效。 这是我的代码

  • 我在pod上部署了SAS Viya编程。这使SASStudio在端口80上运行。我正在尝试通过下面的yaml文件使用nodeport和Inete公开SAS Studio。但在GCP控制台中,后端服务显示不健康,如果我尝试访问Ip,它会遇到默认后端或找不到页面。我可以使用集群IP和节点IP以及端口号访问服务。 如果我使用LoadBalancer服务而不是入口,那么我可以使用LoadBalancer

  • 问题内容: 尝试使用go与postgres数据库通信,准备如下语句: 引发以下错误: 有什么办法吗? 如果需要,我可以添加更多信息。 问题答案: 您应该建立没有SSL加密的数据库连接,如下所示:

  • 只有。这些服务到底有什么不同?端口到底做什么?

  • 本文向大家介绍在Nginx服务器中启用SSL的配置方法,包括了在Nginx服务器中启用SSL的配置方法的使用技巧和注意事项,需要的朋友参考一下 生成证书 可以通过以下步骤生成一个简单的证书: 首先,进入你想创建证书和私钥的目录,例如: 创建服务器私钥,命令会让你输入一个口令: 创建签名请求的证书(CSR): 在加载SSL支持的Nginx并使用上述私钥时除去必须的口令: 启用一个 SSL 虚拟主机