Bryan, thanks again for looking at my issue.
I found this recent post by Joseph St.Amand and used his suggestions to see if that might help.
https://groups.google.com/a/continuum.io/d/msg/bokeh/3MnO_y4NlIc/b-L76vYgDQAJ
``
The new Nginx config adapter after Joseph’s is very similar to what is provided in the Bokeh documentation covering Nginx load balancing:
upstream flask {
server 127.0.0.1:5000;
}
upstream myapp {
least_conn; # Use Least Connections strategy
server 127.0.0.1:5100;
}
server {
listen 80;
location / {
proxy_pass http://flask;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
location /bokeh {
proxy_pass http://myapp;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
error_page 500 501 502 503 504 401 402 403 /500.html;
location = /500.html {
root /var/www/html;
}
}
``
This actually sets up Nginx proxy for my needs quite nicely. Within the local network, the root of the localhost proxies to the Flask server, localhost/bokeh lists all the apps normally listed under localhost:5100/bokeh and I can access all my bokeh server apps individually.
Now I tried embedding a Bokeh app in my Flask app, per Joseph’s suggestion:
app = Flask(name)
bootstrap = Bootstrap(app)
@app.route(‘/’)
@app.route(‘/index’)
def index():
return render_template(‘index.html’)
@app.route(‘/test’)
def data_volume():
bokeh_app = ‘bokeh/myapp’
app_ip = socket.gethostbyname(os.environ['BOKEH_SERVER_HOSTNAME'])
app_port = os.environ['BOKEH_SERVER_PORT']
app_url = 'http://%s:%s/%s' % (app_ip, app_port, bokeh_app)
my_session = pull_session(url=app_url)
host_url = '%s/%s' % (os.environ['HOST_IP'], bokeh_app)
script = server_session(session_id = my_session.id,
url = host_url,
relative_urls=True)
return render_template('test.html', title='Data Volume', script=script)
``
I made sure all of the environment variables are defined correctly before I ran the Flask file.
I can still access the app at localhost/bokeh/app, but pulling up localhost/test generates ‘ProtocolError: Invalid session ID’ in Bokeh Server console.
Here is a snippet from the console output if it tells you anything:
Uncaught exception GET /bokeh/myapp/ws?bokeh-protocol-version=1.0&bokeh-session-id=MCSWNOLZlJOlOp1DuDdpj1ZF8It7fomLqA2c1KIt5U56 (127.0.0.1)
HTTPServerRequest(protocol=‘http’, host=‘127.0.0.1:5100’, method=‘GET’, uri=‘/bokeh/myapp/ws?bokeh-protocol-version=1.0&bokeh-session-id=MCSWNOLZlJOlOp1DuDdpj1ZF8It7fomLqA2c1KIt5U56’, version=‘HTTP/1.1’, remote_ip=‘127.0.0.1’)
``
I am not sure what I could be doing wrong.
···
On Tuesday, January 8, 2019 at 11:16:23 PM UTC, Bryan Van de ven wrote:
Hi,
This is presumably some Nginx configuration problem. The JS code in the browser is going to attempt to open a WS connection back to the server with a URL that has “?bokeh-protocol-version=1.0” in it. For some reason this URL argument is getting lost between the browser and the server. My best (fairly unexperienced) guess is that
proxy_pass http://127.0.0.1:5100$1;
Is, for whatever reason, where the arguments are getting lost. For reference, the docs example does not try to o this kind of pattern matching:
[https://bokeh.pydata.org/en/latest/docs/user_guide/server.html#nginx](https://bokeh.pydata.org/en/latest/docs/user_guide/server.html#nginx)
It’s possible that pattern matching may be workable, but there may be more to it than what’s in the configuration below.
Thanks,
Bryan
On Jan 8, 2019, at 15:01, [email protected] wrote:
I am trying to set up a Nginx reverse proxy to my bokeh server running on port 5100, such that localhost/bokeh points to localhost:5100 (in addition to the root of localhost proxying to a flask server running on port 5000)
I have issued my bokeh server command like this:
bokeh serve myApp --port 5100 --allow-websocket-origin=‘*’
When I go to localhost:5100/myApp, I can see my Bokeh app running fine.
My Nginx proxy set up is like this:
server_name _;
location / {
proxy_pass [http://127.0.0.1:5000](http://127.0.0.1:5000);
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;
}
location ~/bokeh(.*)$ {
proxy_pass http://127.0.0.1:5100$1;
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;
}
error_page 500 501 502 503 504 401 402 403 /500.html;
location = /500.html {
root /var/www/html;
}
}
Now when I connect to localhost/bokeh/myApp, assuming my proxy set up is correct, I expect to see my app running. Instead I get a blank page with this error in the Bokeh server console:
raise ProtocolError(“No bokeh-protocol-version specified”)
Am I doing something wrong in my proxy setup or missing some arguments to pass to the Bokeh server? Please pardon my ignorance with all these setups required for the servers.
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/077ff759-b79d-4f77-a282-99c52a0dba83%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.