WebSocket连接失败-Kubernetes上的JHipster

问题描述 投票:0回答:1

我在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 [不是https] url,然后输入由kubernetes服务设置的端口时-正常。

在microk8s进入中

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

似乎仍然无法正常工作。

如何从https前端开始使用websocket?

jhipster microk8s
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
© www.soinside.com 2019 - 2024. All rights reserved.