weida / nginx_mqtt_preread_module

get some information from the CONNECT message of MQTT
GNU Affero General Public License v3.0
2 stars 1 forks source link

Nginx Stream Pre-read MQTT Module

Nginx module for reading "client" from a stream connection using MQTT protocol.

Build

Build Status

auto/configure --add-module=/path/to/nginx_mqtt_preread_module --with-stream

Configuration

Sample configuration

stream {

      log_format basic '$remote_addr [$time_local] '
                 'clientid: [$mqtt_preread_clientid]  username: [$mqtt_preread_username] '
                 'password: [$mqtt_preread_password] '
                 'protocol: [$mqtt_preread_protocol_name]  version: [$mqtt_preread_protocol_version] ';

      access_log /root/install/nginx/logs/nginx-access.log basic;
      mqtt_preread on;

      upstream backend {
          hash $mqtt_preread_clientid;

          server 10.0.0.7:1883; # upstream mqtt broker 1
          server 10.0.0.8:1883; # upstream mqtt broker 2
          server 10.0.0.9:1883; # upstream mqtt broker 3
      }

      server {
          listen 2883;
          proxy_pass backend;
          proxy_connect_timeout 1s;
      }
}

Configuration directives

mqtt_preread

Enables extracting information from the MQTT CONNECT message at the preread phase.

Embedded Variables