@Bryan, @p-himik
Hi there,
I have two Outstanding things for which i need some help:
Issue 1. Right now I am doing bokeh serve first, then have it served by flask app through gunicorn --bind 0.0.0.0:5000 wsgi:app. (app is my flask app pointing to my bokeh app with file name ‘env.py’.
I am able to host the bokeh app but only as direct mapping of domain to the port number. i.e. https://mydomain will show the app. Here is my config that works and shows my bokeh app for https://mydomain (but only if i directly proxy it to 5006):
location / {
proxy_pass http://127.0.0.1:5006;
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;
}
When i try to proxy pass 'location /'
to port 5000 served by gunicorn i get blank page. What should i change to make it work? Also, what is your recommended way of hosting bokeh apps through nginx? (should we use gunicorn/flask in between bokeh and nginx or directly link bokeh with nginx?)
Issue 2:
I need to host multiple other apps using same nginx server, so i need https://mydomain to show a landing page (not bokeh app) with images hyperlinked to other apps. The issue i am facing is to have location /
for a landing page and location/app1/
(or something like that) for my bokeh app. When i try to use something like below config i get a blank page (for mydomain/env) with only browser tab having title ‘Bokeh Application’ (like i was getting earlier).
location / {
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 /env/ {
rewrite ^/env/(.*)$ /$1 break;
proxy_cache_bypass $http_upgrade
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host:$server_port;
proxy_buffering off;
proxy_pass http://127.0.0.1:5006;
}
proxying to 5000 also didn’t work.
Basically, https://mydomain works but not https://mydomain/env.
Any help in this is appreciated! (apologies for long post, but i thought this info is needed to understand what i am trying to do)
I noticed something while configuring flask and it probably might tell where i am going wrong. I am running bokeh and flask on an Ubuntu vm and testing it thru browser from my laptop (win 10). When i configure flask app to point to the public.ip.of.vm:5006/env then it works (i.e. public.ip.of.vm:5000 on my laptop browser shows the bokeh app), but if i configure flask app to point to localhost:5006/env it shows blank page. What is the correct way to configure flask in this scenario?
from bokeh.resources import CDN
from flask import Flask, render_template
from bokeh.embed import server_document,server_session
from bokeh.client import pull_session
app = Flask(name)
@app.route(“/”)
def index():
#myurl = “http://public.ip.of.vm:5006/env”
myurl = “https://localhost:5006/env”
bokeh_script = server_document(myurl)
return render_template(“index.html”,bokeh_script=bokeh_script)
#run the app
if name == “main”:
app.run(host=‘0.0.0.0’) #app.run(debug=True)