I have 3 linux VMs running on my local machine, of which 2 vms have an instance each of a micro-integrator server node running which are connected through cluster coordination. I'm trying to set up an nginx loadbalancer on the third vm using this documentation nginx-loadbalancer with wso2 . Nginx successfully starts, however when I try to access nginx through the browser as the final step of the doc says, I get a 502 Bad Gateway error. I'm unsure as to where i'm going wrong as everything seemed to be working until the last step. Any help?
As Sanoj mentioned you may have added the wrong ports. A 502 Bad Gateway error
means that NginX was not able to connect to the MI servers. Hence check whether you can connect to all the MI Instances from where NginX running. You can use a tool like telnet
or curl
to test. This will make sure you don't have any connection issues like firewall rules preventing the connection.
This explains all the ports that are used and how you can change them.
This is the official document for NginX configurations for MI.(Seems some ports are incorrect here as well) Following is a sample NginX config with the correct ports.
upstream wso2.ei.com {
server xxx.xxx.xxx.xx1:8290;
server xxx.xxx.xxx.xx2:8290;
}
server {
listen 80;
server_name ei.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://wso2.ei.com;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
upstream ssl.wso2.ei.com {
server xxx.xxx.xxx.xx1:8253;
server xxx.xxx.xxx.xx2:8253;
ip_hash;
}
server {
listen 443;
server_name ei.wso2.com;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.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.wso2.ei.com;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}