当我尝试通过带有 IP 地址的 websocket 连接到 emqx 时,它工作正常。
但是当我使用子域时,连接失败。我的 Apache 配置是
<VirtualHost *:80>
ServerName subdomain.example.com
ServerAlias subdomain.example.com
ServerAdmin admin@domain.in
RewriteEngine On
#RewriteCond %{REQUEST_URI} ^/socket.io [NC]
#RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule ^/mqtt/(.*) ws://localhost:8083/mqtt/$1 [P,L]
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:8083/
ProxyPassReverse / http://localhost:8083/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我将 apache 的日志级别更改为“调试”,这些是错误日志。看起来它正在尝试查找 /mqtt 文件夹。
我已经启用了模式“proxy_wstunnel.load”。如何使用子域连接到 mqtt 和 ws?