我使用emqx的mqtt产品,版本为5.1.4
以下是我的建置过程:
我用helm chart在GKE上安装emqx 5.1.4
且使用helm chart安装ingress-nginx 4.7.1来开放emqx的80、443、1883、8083、8084、18083的端口
再部署一个emqx的ingress来做domain的连线
我的问题是我没办法实现ws://mq.domain.com:8083/mqtt、wss://mq.domain.com:8084/mqtt,没有找到相关的教学文件
以下是一些相关的操作日志
开发者工具:
MQTTX客户端操作:
使用curl指令:
curl -I -N
-H “Connection: Upgrade”
-H “Upgrade: websocket”
-H “Host: domain”
-H “Origin: http://mq.domain.com”
http://mq.domain.com:8083/mqtt
得到的結果是
HTTP/1.1 400 Bad Request
content-length: 0
date: Thu, 12 Oct 2023 09:06:17 GMT
server: Cowboy
以下是我的ingress.yaml内容
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/proxy-read-timeout: “3600”
nginx.ingress.kubernetes.io/proxy-send-timeout: “3600”
nginx.ingress.kubernetes.io/websocket-services: emqx:8083
nginx.ingress.kubernetes.io/server-snippets: |
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_set_header Connection “upgrade”;
proxy_cache_bypass $http_upgrade;
}
name: emqx-ingress
namespace: emqx
spec:
ingressClassName: nginx
rules:
- host: mq.domain.com
http:
paths: - backend:
service:
name: emqx
port:
number: 8083
path: /mqtt
pathType: Prefix - backend:
service:
name: emqx
port:
number: 18083
path: /
pathType: Prefix
tls: - secretName: letsencrypt-certificate-tls
status:
loadBalancer:
ingress: - ip: XX.XXX.XXX.XXX