Docker, nginx reverse-proxy and bokeh server - something is not right, and I don't know where to start to debug

Hi there,

I’ve been trying to dockerise a bokeh server (serverapp), and use it to provide an interactive graph to django website (webapp). I’m trying to use nginx as a reverse-proxy to manage the requests to webapp from the outside world, and between webapp and serverapp.

Webapp is using bokeh.server_document to get the data from the serverapp (and then render that in a script on the page). I believe that server_document requires a url which makes the request to the specified server over the web (rather than a direct network connection). This is causing me all manner of configuration headaches.

If I do this all from one machine it works, If I spin up each of the apps in separate docker containers and hit them, I get the desired response from each container. As soon as I insert nginx and try and network them together I cant get the graph to render. I can’t hit the serverapp with the correct payload to make it run the graph.

I have tried to build up from the nginx example in the documentation (Running a Bokeh server — Bokeh 2.4.2 Documentation) but this gives me an nginx 502 bad gateway error (logs on the serer show the connection is refused despite allow-websockets: *)

I have raised a StackOverflow question with much more detail here: (How to use bokeh-server (server_document) behind nginx, with django, on docker? - Stack Overflow)

Any pointers would be welcomed. This has been a stumbling block for months now.

If you run bokeh serve foo (directory with a main.py inside) or bokeh serve foo.py then the app URL location will be /foo. It seems like you are expecting it to be at /serverapp? Then in order for that you would need:

  • a main.py in a serverapp directory, and invoke bokeh serve serverapp, or
  • a serverapp.py and invoke bokeh serve serverapp.py

Note that if you want the features of “directory format apps” you have to invoke the Bokeh server with the directory, not the main.py directly (that is how you tell the Bokeh server it is directory-format).

Lastly you should generally not include the CDN resources manually for Bokeh server apps. The Bokeh server takes care of BokehJS resource loading itself. Additionally just as an FYI the CDN loads you added also have issues anyway

  • They load the wrong version of BokehJS. You script tags load BokehJS 2.0.1 but you are using Python Bokeh 2.4.2. When you need to add your own script tags, the Python/JS versions must match.

  • Prefer the cdn.bokeh.org domain over the old pydata domain.