I'm trying to setup emqx mqtt broker behind an nginx reverse proxy, unfortunately without success.
I'm using the following configuration.
nginx.conf
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
stream {
upstream stream_backend {
server 127.0.0.1:1883 weight=1;
}
server {
listen 8080;
#proxy_send_timeout 2h;
#proxy_read_timeout 2h;
proxy_connect_timeout 150s;
proxy_timeout 150s;
proxy_pass stream_backend;
proxy_buffer_size 3M;
tcp_nodelay on;
#proxy_protocol on;
}
}
emqx.conf
node {
name = "[email protected]"
cookie = "mysecret"
data_dir = "data"
}
listeners.tcp.default {
bind = "127.0.0.1:1883"
proxy_protocol = true
proxy_protocol_timeout = 30
enable_authn = false
}
dashboard {
listeners.http {
bind = 18083
}
}
nginx and emqx are running within the same docker compose file.
Trying to connect is giving the following error
emqx | 2023-09-26T23:20:47.213039+00:00 [error] supervisor: 'esockd_connection_sup - <0.2858.0>', errorContext: connection_shutdown, reason: {invalid_proxy_info,<<"GET /mqtt HTTP/1.1\r\n">>}, offender: [{pid,<0.3309.0>},{name,connection},{mfargs,{emqx_connection,start_link,[#{enable_authn => false,limiter => undefined,listener => {tcp,default},zone => default}]}}]
Update
Updating the emqx.conf to run native mqtt solved the mqtt connection problem
node {
name = "[email protected]"
cookie = "mysecret"
data_dir = "data"
}
listeners.tcp.default {
bind = "127.0.0.1:1883"
}
dashboard {
listeners.http {
bind = 18083
}
}
