0

我在 Kubernetes [microk8s] 上运行 JHipster 应用程序,并在远程主机上进行入口。

默认情况下,入口设置为 https。

在浏览器控制台中,我得到:

WebSocket connection to 'wss://XXXXXX/websocket/tracker/041/tjk33h4t/websocket?access_token=XXXXXXXXXXXXXXXX' failed: Error during WebSocket handshake: Unexpected response code: 403 其次是

Refused to display 'https://XXXXX/websocket/tracker/iframe.html?access_token=XXXXXXXXXX' in a frame because it set 'X-Frame-Options' to 'deny'

在 application-prod.yml 我有:

  port: 8080
  compression:
    enabled: true
    mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json
    min-response-size: 1024

当我输入 http [not https] url 后跟 kubernetes 服务设置的端口时 - 工作正常。

在 microk8s 入口

  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"

无论如何似乎都不起作用。

如何从 https 前端开始工作 websocket?

4

1 回答 1

0

您可以尝试为 websocket 服务添加注释

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    certmanager.k8s.io/cluster-issuer: tls-issuer
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
    nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "1800"
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/secure-backends: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/websocket-services: SERVICE_NAME
    nginx.org/websocket-services: SERVICE_NAME
于 2019-11-17T03:54:22.217 回答