I’m trying to embed an interactive visualization in another site. It works fine when both the Bokeh server and the site are being run from the same computer, but I’m trying to offload the Bokeh server to a different IP address and use SSL. When I do this, I get a rather strange issue.
https://constellate.dev/GDrzvqv3 is an example visualization, that works fine for me when I navigate to the site directly. But when I then try to embed it using an autoload script, I get the following error from the server:
2022-06-25 21:02:11,677 WebSocket connection opened
2022-06-25 21:02:11,678 ServerConnection created
2022-06-25 21:02:52,405 WebSocket connection opened
2022-06-25 21:02:52,406 Uncaught exception GET /GDrzvqv3/ws (107.137.157.121)
HTTPServerRequest(protocol='http', host='constellate.dev', method='GET', uri='/GDrzvqv3/ws', version='HTTP/1.1', remote_ip='107.137.157.121')
Traceback (most recent call last):
File "/home/nicholas/.cache/pypoetry/virtualenvs/constellate-Kl69nrwf-py3.9/lib/python3.9/site-packages/tornado/websocket.py", line 954, in _accept_connection
open_result = handler.open(*handler.open_args, **handler.open_kwargs)
File "/home/nicholas/.cache/pypoetry/virtualenvs/constellate-Kl69nrwf-py3.9/lib/python3.9/site-packages/tornado/web.py", line 3173, in wrapper
return method(self, *args, **kwargs)
File "/home/nicholas/.cache/pypoetry/virtualenvs/constellate-Kl69nrwf-py3.9/lib/python3.9/site-packages/bokeh/server/views/ws.py", line 139, in open
raise ProtocolError("Subprotocol header is not 'bokeh'")
bokeh.protocol.exceptions.ProtocolError: Subprotocol header is not 'bokeh'
The same thing happened when I tried using Nginx. I’m using Apache now, so here’s the configuration I’m using to do that. (Because the URLs are auto-generated, this doesn’t quite match the config given in the docs, but given that it works when you navigate to the site directly I don’t think I made any really simple goofs setting that up.)
Any advice? Here’s my Apache configuration.
Listen 443
<VirtualHost *:443>
ServerName constellate.dev
SSLEngine On
SSLCertificateFile "/etc/letsencrypt/live/constellate.dev/fullchain.pem"
SSLCertificateKeyFile "/etc/letsencrypt/live/constellate.dev/privkey.pem"
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:5006/$1" [P,L]
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5006/
ProxyPassReverse / http://127.0.0.1:5006/
<Directory />
Require all granted
Options -Indexes
</Directory>
# Alias /static /path/to/bokeh/server/static
# <Directory /path/to/bokeh/server/static>
# # directives to effect the static directory
# Options +Indexes
# </Directory>
</VirtualHost>