Nginx only shows default welcome page, not Bokeh app

Hi, I am trying to run a Bokeh app using nginx to serve it, however nginx only show the default Nginx welcome page when I go to the address of the server. I am running a CentOS 8 VM on Azure and got a private ip address 10.73.162.4. Using ssh to work on the VM. I can go directly to the Bokeh app in the browser on the local machine without any issues, but not by proxy.

I have created a Nginx conf file in /etc/nginx/conf.d/bokeh.conf:

upstream bokeh_site {
    server 127.0.0.1:5100;
}

server {
    listen 80;
    listen [::]:80;

    server_name _;

    access_log  /tmp/bokeh.access.log;
    error_log   /tmp/bokeh.error.log debug;

    location / {
        proxy_pass http://bokeh_site;
        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_buffering off;
    }
}

I have not touched the default Nginx conf file, but have confimred that there is an include to pickup local conf files. I have restarted nginx with sudo systemctl restart nginx.

The bokeh app is just the standard sliders.py which I am running in a server directory fomat:

.
├── sliders
│   └── main.py

I start Bokeh with

bokeh serve sliders/ --allow-websocket-origin=10.73.162.4:5100 --port 5100

and I can view it in the browser with 10.73.162.4:5100/sliders.

But I thought that with Nginx setup I could just use 10.73.162.4 in order to serve the Bokeh app, however this just shows the default Nginx welcome page.

Any help appreciated.

I’m not an expert on nginx, but you might simplify the config in this case by removing the upstream section and just using 127.0.0.1:5100 directly in:

proxy_pass http://127.0.0.1:5100;

I could be wrong, but I think upstream requires an nginx module to be installed, so I just thought in case that is causing a problem. In general, it would be worth looking at the nginx logs to see if it has any complaints.

Another thing that I noticed, which isn’t your current problem but you could encounter when you fix this first stage…:

bokeh serve sliders/ --allow-websocket-origin=10.73.162.4:5100 --port 5100

The web traffic will originate from port 80, so you would probably need that as the web origin instead of the local port 5100 (or 80 is the default anyway):

bokeh serve sliders/ --allow-websocket-origin=10.73.162.4 --port 5100

Hopefully someone with better nginx experience will have more to add, but in the meantime please do check your logs and ensure the config is being loaded too - maybe introduce a deliberate error just to show that problems are being discovered and reported in the logs.

1 Like