簡體   English   中英

400 Bad Request You're speak plain HTTP to an SSL-enabled server port kubernetes pod

[英]400 Bad Request You're speaking plain HTTP to an SSL-enabled server port kubernetes pod

我收到錯誤“ 400 Bad Request Your browser sent an request that this server could not understand. Reason: You're speak plain HTTP to an SSL-enabled server port. 相反,請使用 HTTPS 方案訪問此 ZE6B3931A28D2C4D459,

我想要實現的是:

1. Docker 運行Docker 使用 apache2 和 Shibboleth 的圖像分別在端口 http(8090) 和 https(8443) 上運行,帶有自簽名證書。 使用 docker 在本地運行映像運行良好。 http://localhost:8090/ ----> 工作正常 https://localhost:8443/Shibboleth.sso/Status ----> 給出證書錯誤但接受並忽略后工作正常。 (通過 apache2 000-default.conf ProxyPass /Shibboleth.sso/ https://localhost:8443/Shibboleth.sso/Status 訪問的 Shibboleth 服務)

  1. Kubernetes 平台 下面是為訪問同一個鏡像而創建的部署、服務和入口。
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: test
  name: demo
  labels:
    app: demo
spec:
  #replicas: 1
  selector:
    matchLabels:
      app: demo-pod
  template:
    metadata:
      labels:
        app: demo-pod
    spec:
      containers:
      - image: <repository>public/demo-v1
        name: demo
        ports:
        - containerPort: 8154
          name: demo-ui
        - containerPort: 8090
          name: http
        - containerPort: 8443
          name: https
        securityContext:
          runAsNonRoot: true
          runAsUser: 1000
        resources:
           limits:
             cpu: 1000m
             memory: 8024Mi
           requests:
             cpu: 500m
             memory: 4096Mi 
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: regcred
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  namespace: test
  name: demo-svc
  labels:
    app: demo
spec:
  selector:
    app: demo-pod
  ports:
  - port: 8154
    name: demo-ui
    targetPort: 8154
    protocol: TCP
  - port: 8090
    name: http
    targetPort: 8090
    protocol: TCP
  - port: 8443
    name: https
    targetPort: 8443
    protocol: TCP     
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: test
  name: demo-ing
  labels:
    app: demo
spec:
  ingressClassName: internal
  tls:
  - hosts:
    - demo.example.com
  rules:
  - host: demo.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: demo-svc
            port:
              number: 8090
      - path: /demo-ui
        pathType: Prefix
        backend:
          service:
            name: demo-svc
            port:
              number: 8090
      - path: /Shibboleth.sso
        pathType: Prefix
        backend:
          service:
            name: demo-svc
            port:
              number: 8443 

默認域為 *.example.com 使用 https

when hitting **https://demo.example.com/ --> http://<pod-IP>:8090**  and working fine 
but when accessing the **https://demo.example.com/Shibboleth.sso/Status --- > http://<pod-IP>:8443**

並返回“ 400 Bad Request 您的瀏覽器發送了一個此服務器無法理解的請求。原因:您說的是簡單的 HTTP 到啟用 SSL 的服務器端口。而是使用 HTTPS 方案來訪問此 ZE6B391A8A5803D2C4D485903A

我已經通過入口注釋和 apache2 重定向嘗試了多種解決方案,但似乎沒有任何幫助。

在 apache2 上進行重定向時,它不會將本地主機作為變量。

 RewriteEngine on
 ReWriteCond %{SERVER_PORT} !^8443$
 RewriteRule ^/Shibboleth.sso(.*) https://localhost:8443/Shibboleth.sso/$1 [NC,R,L]

不考慮本地主機並將其作為 dns。

還嘗試在入口級別重定向,這也給出了 404 not found 錯誤。

請在這里幫忙!!!

您能否嘗試將此注釋添加到您的入口文件中?

annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/secure-backends: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM