This documentation is for WSO2 IoT Server 3.1.0. View the documentation for the latest release.
Configuring the Load Balancer - IoT Server 3.1.0 - WSO2 Documentation
                                                                                                                                                                                                                                                                                                                                                                                                                                                   
||
Skip to end of metadata
Go to start of metadata

This section provides instructions on how to configure Nginx as the load balancer. You can use any load balancer for your setup.

The location of the file varies depending on how you installed the software on your machine. For many distributions, the file is located at /etc/nginx/nginx.conf. If it does not exist there, it may also be at /usr/local/nginx/conf/nginx.conf or /usr/local/etc/nginx/nginx.conf. You can create separate files inside the conf.d directory for each configuration. Three different configuration files are used for the Manager, Key Manager and Worker nodes in the example provided in this page.

Before you begin

You need to have a signed SSL certificate before starting. When generating the certificate make sure to add the following four URLs as Server Name Indications (SNI).

Workeriots310.wso2.com
gateway.iots310.wso2.com
Managermgt.iots310.wso2.com
Key Managerkeymgt.iots310.wso2.com
  1. Create a file named mgt.conf in the /nginx/conf.d directory and add the following to it. This will be used by the Manager node to load balance.


    upstream mgt.iots310.wso2.com {
            ip_hash;
            server 192.168.57.124:9763;
    }
    
    server {
            listen 80;
            server_name mgt.iots310.wso2.com;
            client_max_body_size 100M;
            location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass http://mgt.iots310.wso2.com;
    
                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
    }
    
    
    
    upstream ssl.mgt.iots310.wso2.com {
        ip_hash;
        server 192.168.57.124:9443;
    
    }
    
    server {
    listen 443;
        server_name mgt.iots310.wso2.com;
        ssl on;
        ssl_certificate /opt/keys/star_wso2_com.crt;
        ssl_certificate_key /opt/keys/iots310_wso2_com.key;
     client_max_body_size 100M;
        location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass https://ssl.mgt.iots310.wso2.com;
    
                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
    }
    
  2. Create a file named wkr.conf in the /nginx/conf.d directory and add the following to it. This will be used by the first worker node to load balance.

    upstream iots310.wso2.com {
            ip_hash;
            server 192.168.57.125:9763;
            server 192.168.57.126:9763;
    }
    
    server {
            listen 80;
            server_name iots310.wso2.com;
            location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass http://iots310.wso2.com;
    
                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
    }
    
    
    
    upstream ssl.iots310.wso2.com {
        ip_hash;
        server 192.168.57.125:9443;
        server 192.168.57.126:9443;
    }
    
    server {
    listen 443;
        server_name iots310.wso2.com;
        ssl on;
        ssl_certificate /opt/keys/star_wso2_com.crt;
        ssl_certificate_key /opt/keys/iots310_wso2_com.key;
        location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass https://ssl.iots310.wso2.com;
    
                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
    }
  3. Create a file named gateway.conf in the /nginx/conf.d directory and add the following to it. This will be used by the gateway worker node to load balance.

    upstream gateway.iots310.wso2.com {
            ip_hash;
            server 192.168.57.125:8280;
            server 192.168.57.126:8280;
    }
    
    server {
            listen 80;
            server_name gateway.iots310.wso2.com;
            location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass http://gateway.iots310.wso2.com;
    
                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
    }
    
    
    
    upstream ssl.gateway.iots310.wso2.com {
        ip_hash;
        server 192.168.57.125:8243;
        server 192.168.57.126:8243;
    }
    
    server {
    listen 443;
        server_name gateway.iots310.wso2.com;
        ssl on;
        ssl_certificate /opt/keys/star_wso2_com.crt;
        ssl_certificate_key /opt/keys/iots310_wso2_com.key;
        location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass https://ssl.gateway.iots310.wso2.com;
    
                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
    }
  4. Create a file named keymgt.conf in the /nginx/conf.d directory and add the following to it. This will be used by the key manager node to load balance.

    upstream keymgt.iots310.wso2.com {
            ip_hash;
            server 192.168.57.127:9763;
    }
    
    server {
            listen 80;
            server_name keymgt.iots310.wso2.com;
            location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass http://keymgt.iots310.wso2.com;
    
                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
    }
    
    upstream ssl.keymgt.iots310.wso2.com {
        ip_hash;
        server 192.168.57.127:9443;
    
    }
    
    server {
    listen 443;
        server_name keymgt.iots310.wso2.com;
        ssl on;
        ssl_certificate /opt/keys/star_wso2_com.crt;
        ssl_certificate_key /opt/keys/iots310_wso2_com.key;
        location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass https://ssl.keymgt.iots310.wso2.com;
    
                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
    }

What's next?

Let's identify the databases and datasources used in WSO2 IoT Server and set them up for the clustered environment. For more information, see Setting Up the Databases for Clustering.

  • No labels