Nginx SSL proxy_pass to Bokeh server

Hi all,

I want to access my Bokeh server which invoked by my Flask app in Nginx through SSL. And I set up my server according to the document https://bokeh.pydata.org/en/latest/docs/user_guide/server.html.

Part of my Nginx defaul.conf as following.

 location /crossfilter/ {
     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-Proto $scheme;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header Host $host:$server_port;
     proxy_buffering off;
 }

 location ~* \.php$ {
     root /var/www/html;
     try_files $uri =404;
     fastcgi_split_path_info ^(.+\.php)(/.+)$;
     fastcgi_pass php:9000;
     fastcgi_index index.php;
     include fastcgi_params;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_param PATH_INFO $fastcgi_path_info;
 }

``

And the Bokeh server which invoked by flask as the following code:

bokeh_process = subprocess.Popen(
[‘python’, ‘-m’, ‘bokeh’, ‘serve’, ‘crossfilter.py’, ‘–allow-websocket-origin=localhost:5006’, ‘–use-xheaders’, ‘–log-level=debug’, ‘–log-file=/var/log/bokeh.log’], stdout=subprocess.PIPE)

``

And the log file looks the server is on:

2019-02-15 09:17:52,301 <class ‘bokeh.server.views.static_handler.StaticHandler’>)]
2019-02-15 09:17:52,303 Bokeh app running at: http://localhost:5006/crossfilter
2019-02-15 09:17:52,304 Starting Bokeh server with process id: 37

``

When I try to access my website by https://mysite/crossfilter, I got Nginx error log:

2019/02/15 09:20:56 [error] 68#68: *38 open() “/var/www/html/crossfilter” failed (2: No such file or directory),

``

any idea?

thanks,

Dave

I am not so familiar with PHP and web servers and it is not clear to me how you have set things up.
I looks like you are starting your Bokeh server on default port 5000 but in your Nginx config you specify 5006 as the port number.

Let me ask/clarify:

  1. You are trying to run a Bokeh server app, so after serving a page there is continuous communication between the BokehJS in the browser and the Bokeh server through the NginX/Flask?

  2. You are running Bokeh server on default port 5000

  3. Your Flask runs on default port 5006

  4. The log file above comes from Flask server? Usually Bokeh server print similar output when starting… But the message cannot be from Bokeh server as it should run on port 5000, according to the subprocess.Popen() as you don’t specify “address” or “port” there

It looks like the nginx is trying to serve a page while the page should be served by Flask based on json/JS data it receives from the Bokeh server (possibly rendered by a Jinja2 template engine?)

Maybe you could post more code, especially how do you serve the HTML in Flask?

···

On Friday, February 15, 2019 at 10:35:12 AM UTC+1, Dave Wen wrote:

Hi all,

I want to access my Bokeh server which invoked by my Flask app in Nginx through SSL. And I set up my server according to the document https://bokeh.pydata.org/en/latest/docs/user_guide/server.html.

Part of my Nginx defaul.conf as following.

 location /crossfilter/ {
     proxy_pass http://[127.0.0.1:5006](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-Proto $scheme;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header Host $host:$server_port;
     proxy_buffering off;
 }

 location ~* \.php$ {
     root /var/www/html;
     try_files $uri =404;
     fastcgi_split_path_info ^(.+\.php)(/.+)$;
     fastcgi_pass php:9000;
     fastcgi_index index.php;
     include fastcgi_params;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_param PATH_INFO $fastcgi_path_info;
 }

``

And the Bokeh server which invoked by flask as the following code:

bokeh_process = subprocess.Popen(
[‘python’, ‘-m’, ‘bokeh’, ‘serve’, ‘crossfilter.py’, ‘–allow-websocket-origin=localhost:5006’, ‘–use-xheaders’, ‘–log-level=debug’, ‘–log-file=/var/log/bokeh.log’], stdout=subprocess.PIPE)

``

And the log file looks the server is on:

2019-02-15 09:17:52,301 <class ‘bokeh.server.views.static_handler.StaticHandler’>)]
2019-02-15 09:17:52,303 Bokeh app running at: http://localhost:5006/crossfilter
2019-02-15 09:17:52,304 Starting Bokeh server with process id: 37

``

When I try to access my website by https://mysite/crossfilter, I got Nginx error log:

2019/02/15 09:20:56 [error] 68#68: *38 open() “/var/www/html/crossfilter” failed (2: No such file or directory),

``

any idea?

thanks,

Dave