I am running a flask app and I have embedded a bokeh/panel app inside it. I can see the panel/bokeh app working fine on localhost. But I cannot see the app on the website (referred to as mysite.com here). There are no errors on the bokehserver or the gunicorn log files. I can see the flask template headers but the app just does not show up.
I have used this same setup in the past and it worked fine. I am having this trouble after updating my environment to:
Python-3.12
Bokeh-3.6.1
Panel-1.5.3
Flask-2.2.3
Here is my flask view entry for the embedded app:
@register_breadcrumb(app, '.tools.myapp', Special app')
def isotensoid():
script = server_document(url="http://www.mysite.us/apps/myapp")
return render_template("myapp.html", script=script, template="Flask")
I am also using nginx with reverse proxy configured as:
##
upstream gunicorn {
server 127.0.0.1:8000;
}
upstream myapps {
least_conn; # Use Least Connections strategy
server 127.0.0.1:5100; # The Bokeh server
}
server {
listen 80;
server_name mysite.us www.mysite.com;
# Main Flask application
location / {
proxy_pass http://gunicorn;
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;
}
# Bokeh server at /apps/*
location /apps/ {
proxy_pass http://myapps;
#proxy_pass http://127.0.0.1:5100/apps/; # Use trailing slash for consistency with prefix
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-Proto $scheme;
# WebSocket headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
}
# Static files for Flask
location /static/ {
alias /home/ubuntu/flask/mysite/app/static/;
autoindex on;
# Prevent unnecessary redirects
proxy_redirect off;
}
# Common files (if applicable)
location /common/ {
alias /home/ubuntu/users/common/;
}
# Custom error pages
error_page 500 501 502 503 504 401 402 403 /500.html;
location = /500.html {
root /var/www/html;
}
}
The bokeh server is run via gunicorn:
user=ubuntu
directory=/home/ubuntu/bokeh
environment=BOKEH_RESOURCES='inline'
command = /home/ubuntu/miniforge3/envs/myenv/bin/panel serve myapp --address=127.0.0.1 --port 5100 --allow-websocket-origin=www.mysite.com --allow-websocket-origin=mysite.com --allow-websocket-origin=127.0.0.1:5100 --allow-websocket-origin=x.x.x.x:5100 --prefix /apps --disable-index --disable-index-redirect --use-xheaders --log-level=debug
environment=PATH="/home/ubuntu/miniforge3/envs/myenv/bin:/usr/local/bin:/usr/bin:/bin", PYTHONPATH="/home/ubuntu/miniforge3/envs/myenv/lib/python3.12/site-packages"
autostart=true
autorestart=true
stderr_logfile=/var/log/bokehserver.err.log
stdout_logfile=/var/log/bokehserver.out.log