Nginx load balancing for our application works in Windows, however when we try to run the same in
- Linux we are getting the following error;
2021/08/12 15:11:38 [error] 14615#0: *2 open() “/usr/local/nginx/html/charts/bar_stack” failed (2: No such file or directory), client: 10.61.44.155, server: localhost, request: “GET /charts/bar_stack?parms=%7B%22object_id%22:4,%22columns%22:%7B%22x%22:%22petal_length%22,%22y%22:%22petal_width%22%7D,%22columns_type%22:%7B%22x%22:%22float64%22,%22y%22:%22float64%22%7D,%22value%22:%22None%22,%22chart_type%22:%22barstack%22,%22aggregate%22:%7B%22x%22:%22sum%22,%22y%22:%22None%22%7D,%22legends%22:%7B%22color%22:%22petal_length%22,%22size%22:%22None%22,%22shape%22:%22None%22%7D,%22valueaggregate%22:%22None%22,%22filter%22:%22None%22,%22screen%22:%22None%22,%22user_id%22:1%7D HTTP/1.1”, host: “localhost”
In the windows environment when we request for “/charts” end-point we hit the the bokeh.conf and the request is then handled by the running 2302/3/4 rest_server_charts services. But THE SAME SETUP in Linux it is trying to look up for “/charts” in “/usr/local/nginx/html/charts/bar_stack” which is not correct.
We have followed the following configuration steps to setup NGINX in both Linux and Windows environments;
In the Windows environment, we have followed the official document for installation of Nginx [Load balancing with Nginx], provided on the official bokeh website. Installation in Windows;
- Download and install NGINX (http://nginx.org/download/nginx-1.20.1.zip)
- Configure an bokeh.conf file.
upstream bokehnginx {
server localhost:2302;
server localhost:2303;
server localhost:2304;
}
server {
listen 80;
server_name localhost;
location /charts {
proxy_pass http://bokehnginx/charts;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$Server_port;
proxy_buffering off;
}
}
- Include the below line in nginx.conf file.
- < include D:/XXXXX/XXXXX/bokeh.conf; >
- Setup the rest_server_charts.py code accordingly.
- Run the 3 rest_server_charts services for 2302/3/4 separately.
- With this when we make calls from our application;
- Application URL
<http://localhost:2302/charts/bar_stack?parms=%7B%22object_id%22:4,%22columns%22:%7B%22x%22:%22petal_length%22,%22y%22:%22petal_width%22%7D,%22columns_type%22:%7B%22x%22:%22float64%22,%22y%22:%22float64%22%7D,%22value%22:%22None%22,%22chart_type%22:%22barstack%22,%22aggregate%22:%7B%22x%22:%22sum%22,%22y%22:%22None%22%7D,%22legends%22:%7B%22color%22:%22petal_length%22,%22size%22:%22None%22,%22shape%22:%22None%22%7D,%22valueaggregate%22:%22None%22,%22filter%22:%22None%22,%22screen%22:%22None%22,%22user_id%22:1%7D>
- Calling the charts via NGINX: it will internally pick up the ports mapped according to the configuration.
<http://localhost:/charts/bar_stack?parms=%7B%22object_id%22:4,%22columns%22:%7B%22x%22:%22petal_length%22,%22y%22:%22petal_width%22%7D,%22columns_type%22:%7B%22x%22:%22float64%22,%22y%22:%22float64%22%7D,%22value%22:%22None%22,%22chart_type%22:%22barstack%22,%22aggregate%22:%7B%22x%22:%22sum%22,%22y%22:%22None%22%7D,%22legends%22:%7B%22color%22:%22petal_length%22,%22size%22:%22None%22,%22shape%22:%22None%22%7D,%22valueaggregate%22:%22None%22,%22filter%22:%22None%22,%22screen%22:%22None%22,%22user_id%22:1%7D>
windows - nginx.conf
#user nobody;
worker_processes 1;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include D:/XXXXX/XXXXX/services/bokeh.conf;
}
We have followed the exact same approach in Linux as well but for installation of Nginx, in this environment.
The rest of the steps are, similar to just as we followed in the Windows environment.
linux - nginx.conf
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include /opt/XXXXX/XXXXX/services/bokeh.conf;
}
Stackoverflow: https://stackoverflow.com/questions/68759620/nginx-bokeh-load-balancing-issue