Bài đăng phổ biến

Thursday, September 1, 2022

Resolved : Nginx reverse proxy for AWS IoT MQTT over TLS

Problem : you can not configure http to reverse proxy for aws iot mqtt ,  java client would return these errors : socket is closed.


Resolved : 

You must use nginx module: ngx_stream_proxy_module ( like network load balancer) this is a template to resolve : 


        map $ssl_preread_server_name $domain {
        stg-iot.yourdomain  stg-iot;
        iot.yourdomain prod-iot;

        upstream stg-iot {

       upstream prod-iot {
  map $ssl_server_name $targetCert {
    stg-iot.yourdomain /etc/nginx/ssl/star_yourdomain.crt;
    iot.yourdomain /etc/nginx/ssl/star_yourdomain.crt;

    map $ssl_server_name $targetCertKey {
    stg-iot.yourdomain /etc/nginx/ssl/star_yourdomain.key;
    iot.yourdomain /etc/nginx/ssl/star_yourdomain.key;

        server {
                listen 443;
    ssl_certificate     $targetCert;
    ssl_certificate_key $targetCertKey;
                proxy_pass $domain;
                ssl_preread on;



Feel free to use them without concern! 

Nginx reverse proxy for AWS IoT MQTT over TLS 

Nguyen Si Nhan

1 comment:

  1. Very useful configuration sample to setup Nginx Stream Proxy for MQTT protocol. Awesome big bro.


Thanks for your join,we will be reply to you asap.