Kubernetes入口编辑:HTTP 400错误请求-普通的HTTP请求已发送到HTTPS

时间:2018-11-29 12:51:39

标签: kubernetes kubernetes-ingress nginx-ingress

在完全手动加载或通过自动作业(通过修改白名单IP的更新更新入口的自动作业)编辑入口后,是否有任何理由可以完美加载该web应用程序提供一个*HTTP 400 Bad request - The plain HTTP request was sent to HTTPS*端口?

显然,当我们在清除webapp部署 ...

之后重新部署webapp时,此问题已得到解决。

任何指向此操作的指针都将非常有用,因为这会在我们的PROD环境中发生,而在任何较低的环境中都无法重现。 注意事项:- -在较低的环境和产品环境中,Nginx Ingress控制器的设置相同。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/force-ssl-redirect: "true"
    ingress.kubernetes.io/ingress.allow-http: "false"
    ingress.kubernetes.io/proxy-body-size: 20M
    ingress.kubernetes.io/secure-backends: "true"
    ingress.kubernetes.io/whitelist-source-range: xxx.yy.zz.pp/32, yyy.ss.dd.kkl/32
    ingress.kubernetes.io/whitelist-source-range-status: unlocked
creationTimestamp: 2018-11-29T15:34:05Z
generation: 5
 labels:
   app: xyz-abc-pqr
  name: xxxx-webapp-yyyy-zzzz
  namespace: nspsace-name
  resourceVersion: "158237270"
  selfLink: /apis/extensions/v1beta1/namespaces/nspsace-name/ingresses/xxxx-webapp-yyyy-zzzz
  uid: 348f892e-f3ec-11e8-aa6f-0a0340041348
  spec:
   rules:
    - host: ssssssss.wwwwweewwerwerw.co.uk
      http:
      paths:
       - backend:
          serviceName: xxxx-webapp-yyyy-zzzz
          servicePort: 443
        path: /
    - host: xxxx-webapp-yyyy-zzzz.bbbbv.lasdfkla.ajksdfh.ioohhsaf.pp
     http:
       paths:
        - backend:
          serviceName: xxxx-webapp-yyyy-zzzz
          servicePort: 443
       path: /
     tls:
       - hosts:
          - ssssssss.wwwwweewwerwerw.co.uk
          - xxxx-webapp-yyyy-zzzz.bbbbv.lasdfkla.ajksdfh.ioohhsaf.pp
         secretName: xxxx-webapp-yyyy-zzzz-server-tls
     status:
       loadBalancer:
        ingress:
         - {}

1 个答案:

答案 0 :(得分:2)

入口控制器及其更新配置的方式可能有问题。我假设您使用的是nginx ingress controller,因此您可以在之后检查配置:

$ kubectl cp <nginx-ingress-controller-pod>:nginx.conf nginx.conf.before
$ kubectl edit ingress <your-ingress>
$ kubectl cp <nginx-ingress-controller-pod>:nginx.conf nginx.conf.after
$ diff nginx.conf.before nginx.conf.after

您可以看到nginx可能会发生这种情况,原因如下:Dealing with nginx 400 "The plain HTTP request was sent to HTTPS port" error