On Apr 20, 2016, at 7:30 AM, Hexin Chen <[email protected]> wrote:
Thank you very much, Bryan!
It's a really detailed walk-through. It took me some time to upgrade Apache from 2.2 to 2.4 and now I've loaded the modules and set the virtual host. However, I got 503 error Service Unavailable. The main site is running fine and the error only occurs when I try to visit the bokeh url
[root@localhost ~]# bokeh serve --log-level=debug --port 5100 --host "pub.domain":80 /var/www/html/bokeh_app/sliders.py
DEBUG:bokeh.server.tornado:Allowed Host headers: ['pub.domain:80']
DEBUG:bokeh.server.tornado:These host origins can connect to the websocket: ['pub.domain:80', 'localhost:5100']
DEBUG:bokeh.server.tornado:Patterns are: [('/sliders/?', <class 'bokeh.server.views.doc_handler.DocHandler'>, {'application_context': <bokeh.server.application_context.ApplicationContext object at 0x7fa1f3f0dad0>, 'bokeh_websocket_path': '/sliders/ws'}), ('/sliders/ws', <class 'bokeh.server.views.ws.WSHandler'>, {'application_context': <bokeh.server.application_context.ApplicationContext object at 0x7fa1f3f0dad0>, 'bokeh_websocket_path': '/sliders/ws'}), ('/sliders/autoload.js', <class 'bokeh.server.views.autoload_js_handler.AutoloadJsHandler'>, {'application_context': <bokeh.server.application_context.ApplicationContext object at 0x7fa1f3f0dad0>, 'bokeh_websocket_path': '/sliders/ws'}), ('/static/(.*)', <class 'bokeh.server.views.static_handler.StaticHandler'>)]
INFO:bokeh.command.subcommands.serve:Starting Bokeh server on port 5100 with applications at paths ['/sliders']
DEBUG:bokeh.server.tornado:[pid 25108] 0 clients connected
DEBUG:bokeh.server.tornado:[pid 25108] /sliders has 0 sessions with 0 unused
DEBUG:bokeh.server.tornado:[pid 25108] 0 clients connected
DEBUG:bokeh.server.tornado:[pid 25108] /sliders has 0 sessions with 0 unused
DEBUG:bokeh.server.tornado:[pid 25108] 0 clients connected
DEBUG:bokeh.server.tornado:[pid 25108] /sliders has 0 sessions with 0 unused
Here's my httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
<VirtualHost *:80>
ServerName pub.domain
CustomLog logs/bokeh-access.log combined
ErrorLog logs/bokeh-error.log
# for a bokeh server running internally on port 5100
ProxyPreserveHost On
ProxyPass /bokeh_app/sliders/ws ws://127.0.0.1:5100/sliders/ws
ProxyPassReverse /bokeh_app/sliders/ws ws://127.0.0.1:5100/sliders/ws
ProxyPass /bokeh_app/sliders http://127.0.0.1:5100/sliders/
ProxyPassReverse /bokeh_app/sliders http://127.0.0.1:5100/sliders/
<Directory />
Require all granted
Options -Indexes
</Directory>
</VirtualHost>
Then I also tried to open port 5100 withe firewalld to public, I visited the server.ip:5100/sliders and I can see the plotting.
[root@localhost ~]# bokeh serve --log-level=debug --port 5100 --host srv.ip:5100 /var/www/html/bokeh_app/sliders.py
DEBUG:bokeh.server.tornado:Allowed Host headers: ['srv.ip:5100']
DEBUG:bokeh.server.tornado:These host origins can connect to the websocket: ['srv.ip:5100', 'localhost:5100']
DEBUG:bokeh.server.tornado:Patterns are: [('/sliders/?', <class 'bokeh.server.views.doc_handler.DocHandler'>, {'application_context': <bokeh.server.application_context.ApplicationContext object at 0x7f0000524b10>, 'bokeh_websocket_path': '/sliders/ws'}), ('/sliders/ws', <class 'bokeh.server.views.ws.WSHandler'>, {'application_context': <bokeh.server.application_context.ApplicationContext object at 0x7f0000524b10>, 'bokeh_websocket_path': '/sliders/ws'}), ('/sliders/autoload.js', <class 'bokeh.server.views.autoload_js_handler.AutoloadJsHandler'>, {'application_context': <bokeh.server.application_context.ApplicationContext object at 0x7f0000524b10>, 'bokeh_websocket_path': '/sliders/ws'}), ('/static/(.*)', <class 'bokeh.server.views.static_handler.StaticHandler'>)]
INFO:bokeh.command.subcommands.serve:Starting Bokeh server on port 5100 with applications at paths ['/sliders']
DEBUG:bokeh.server.tornado:[pid 29638] 0 clients connected
DEBUG:bokeh.server.tornado:[pid 29638] /sliders has 0 sessions with 0 unused
INFO:tornado.access:200 GET /sliders (browser.ip) 69.91ms
INFO:bokeh.server.views.ws:WebSocket connection opened
DEBUG:bokeh.server.views.ws:Receiver created for Protocol(u'1.0')
DEBUG:bokeh.server.views.ws:ServerHandler created for Protocol(u'1.0')
INFO:bokeh.server.views.ws:ServerConnection created
DEBUG:bokeh.server.session:Sending pull-doc-reply from session 'KBic9cpoZvfKqVaIaZqcnp92nfjX2Yf9ZFEuerk0l7ZY'
DEBUG:bokeh.server.tornado:[pid 29638] 1 clients connected
DEBUG:bokeh.server.tornado:[pid 29638] /sliders has 1 sessions with 0 unused
I don't know why the application is not responding to the requests from Apache, although the settings seems fine to me.
Thanks a lot!
Hexin
On Tuesday, April 19, 2016 at 2:58:27 AM UTC+8, Bryan Van de ven wrote:
Hi Hexin,
OK I did try updating to Apache 2.4 and it works. Here is the configuration I used:
<VirtualHost *:8080>
ServerName localhost
CustomLog "/Users/bryan/Sites/logs/access_log" combined
ErrorLog "/Users/bryan/Sites/logs/error_log"
ProxyPreserveHost On
ProxyPass /sliders/ws ws://127.0.0.1:5100/sliders/ws
ProxyPassReverse /sliders/ws ws://127.0.0.1:5100/sliders/ws
ProxyPass /sliders http://127.0.0.1:5100/sliders/
ProxyPassReverse /sliders http://127.0.0.1:5100/sliders/
<Directory />
Require all granted
Options -Indexes
</Directory>
Alias /static /Users/bryan/work/bokeh/bokeh/server/static
<Directory /Users/bryan/work/bokeh/bokeh/server/static>
# directives to effect the static directory
Options +Indexes
</Directory>
</VirtualHost>
With this Bokeh server invocation:
bokeh serve --log-level=debug --port 5100 --host localhost:8080 sliders.py
Again you will need to customize for your particular deployment, but hopefully this points the way. As a final note, you do also need to make sure this Apache module is loaded:
mod_proxy_wstunnel - Apache HTTP Server Version 2.4
In order for the websocket forwarding to work. I also enabled mod_proxy_html but I don't know if that is necessary and I have to switch to other tasks.
Thanks,
Bryan
> On Apr 18, 2016, at 12:26 PM, Bryan Van de Ven <[email protected]> wrote:
>
> Hi Hexin,
>
> Here is some more info that might help you further along. I apologize I can't provide a complete example, I have to prepare some talks this week.
>
> Using the vhost block below, things *almost* work. It is not connecting the websocket. I gather this is because I have Apache 2.2 installed via OSX brew, and I think you need Apache >= 2.4 (or perhaps extra config with earlier versions) to enable websocket forwarding. I will have to leave figuring that out to you or someone else on the mailing list:
>
> <VirtualHost *:8080>
> ServerName localhost
>
> CustomLog "/Users/bryan/Sites/logs/project.dev-access_log" combined
> ErrorLog "/Users/bryan/Sites/logs/project.dev-error_log"
>
> # for a bokeh server running internally on port 5100
> ProxyPreserveHost On
> ProxyPass /app http://127.0.0.1:5100/sliders/
> ProxyPassReverse /app http://127.0.0.1:5100/sliders/
>
> <Directory />
> Order Allow,Deny
> Allow From All
> Options -Indexes
> </Directory>
>
> # better to copy BokehJS static files to your normal /static location like this,
> # but other configurations would be possible...
>
> Alias /static /Users/bryan/work/bokeh/bokeh/server/static
> <Directory /Users/bryan/work/bokeh/bokeh/server/static>
> # directives to effect the static directory
> Options +Indexes
> </Directory>
>
> </VirtualHost>
>
> Then I ran bokeh server like this:
>
> bokeh serve --port 5100 --host localhost:8080 sliders.py
>
> With all of this, the initial connection and static resources load fine, but the websocket does not connect. So that is the part to figure out.
>
> Things you will want to change for your actual deploy:
>
> * the --host should not be localhost:8080, it should be *whatever users will actually navigate to*, i.e. the host name of the public facing apache server
> * if you want bokeh server to serve the static files instead of copying them too your normal /static location as part of your deploy, you probably want to add a --prefix
>
> I look forward to hearing back about how this works out, and also adding a fully complete Apache example to the User's Guide when I can devote time to it.
>
> Bryan
>
>
>
>> On Apr 18, 2016, at 11:04 AM, Bryan Van de Ven <[email protected]> wrote:
>>
>> Hi Hexin,
>>
>> Nginx is definitely not a requirement. It was simply the case that Nginx happened to be the thing we were familiar with, that we could document well in the time constraints we had. It should definitely be possible to use Bokeh behind other front-ends, and in fact I would very much like to document how to do that.
>>
>> Here's a few high-level requirements that might help:
>>
>> * Bokeh server apps use websockets. Whatever is in front of the bokeh server needs to be configured to forward websocket traffic. In an Nginx config, you'd have something like:
>>
>> proxy_pass http://127.0.0.1:5100;
>> proxy_set_header Upgrade $http_upgrade;
>> proxy_set_header Connection "upgrade";
>> proxy_http_version 1.1;
>>
>> Where the ip/port there is the internal ip/port that you have started the bokeh server on. It looks like there is some information about configuring Apache to forward websockets here:
>>
>> node.js - WebSockets and Apache proxy: how to configure mod_proxy_wstunnel? - Stack Overflow
>>
>> * Bokeh server needs to receive the "Host" field from the HTML request. Whatever is in front of the bokeh server needs to forward this. In Nginx, it looks like this:
>>
>> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>> proxy_set_header Host $host:server\_port;
>>
>> I'm not sure offhand what that looks like for Apache \(I have not used Apache, maybe someone else on the list can chime in\)\.
>>
>> \* The Bokeh server host whitelist needs to have the \*public\-facing\* host added\. So if users are navigating to "foo\.com" then the server needs to be started with
>>
>> \-\-host "foo\.com"
>>
>> This value is matched up with the "Host" that the proxy forwards on to the bokeh server\. They have to match\. This is to guard against certain kinds of malicious attacks that involve spoofing Host fields in requests\.
>>
>> \* You can add multiple \-\-host fields\. If you also want to be able to connect from localhost \(for testing or whatever\) then you'd need to add that, explicitly\. If you don't specify any \-\-host at all, then bokeh server adds "localhost" as a default, but if you add \*any\* \-\-host then the server \*only\* configures the \-\-host values that are explicitly given \(no more default "localhost"\)\. But note: adding "localhost" to the \-\-host is probably not something you would want to do "in production", where all access to the server should go through Nginx, or Apache, or whatever\.
>>
>> \* All of this assumes you are not also using/needing SSL \(https\), which would require a few additional configurations for the bokeh server, and probably quite alot of additional configuration for Apache\.
>>
>> \-\-\-\-\-\-\-\-\-
>>
>> For completeness, I will say that another possible option is to simply run the server publicly\-facing and then embed directly from the server using iframes, but there are a number of disadvantages to this approach \(e\.g\. there's no way to scale things if necessary\)\.
>>
>> Thanks,
>>
>> Bryan
>>
>>
>>> On Apr 18, 2016, at 2:33 AM, Hexin Chen <chenhe\.\.\.@gmail\.com> wrote:
>>>
>>> I'm new to Bokeh and I'm trying to run multiple apps in one directory, like the demo site:
>>>
>>> • http://demo.bokehplots.com/apps/movies
>>> • http://demo.bokehplots.com/apps/selection_histogram
>>> • http://demo.bokehplots.com/apps/weather
>>> First I'll introduce the enviroment of the server I'm using\. I'm running a RedHat 6\.4 x86\_64 with Apache 2\.2\.15, MySQL 5\.1\.73, and Anaconda 2\.4 \(Python 2\.7, Bokeh 0\.11\.1\)\. I have direct access to the server \(it belongs to my department\) and it has its own IP address\. The web server on port 80 hosts a WordPress blog mainly and serveral static HTML pages, for example, domain\.url will direct to domain\.url/blog/ and that's the main WP page, there're links to domain\.url/visualization/processing/ and under processing there're some Java applets of our visualization projects\. These files and index pages are under /var/www/html/visualization/processing\.
>>>
>>>
>>>
>>> I'm trying to show bokeh apps in a similar ways\. If a vistor goes to domain\.url/visualization/bokeh\_apps, a page will show up like demo\.bokehplots\.com, and then the vistor can click to domain\.url/visualization/bokeh\_apps/proj01, domain\.url/visualization/bokeh\_apps/proj02, etc\. So I assume the Apache server needs to redirect to different bokeh apps on different ports when it recognize the URL path\.
>>>
>>>
>>>
>>> The first problem I ran into is the host whitelist\. I ran the command:
>>>
>>> \[uid@localhost bokeh\_apps\] bokeh serve --show myapp --port 5100 --host 127.0.0.1:80
>>> A Window popped out and I had to quit the "Elinks", and the output kept going:
>>>
>>> INFO:bokeh.server.tornado:Rejected connection from host 'localhost:5100' because it is not in the --
>>> host whitelist
>>> WARNING
>>> :tornado.access:403 GET /myapp (::1) 1.71ms
>>>
>>> DEBUG
>>> :bokeh.server.tornado:[pid 834] 0 clients connected
>>> I googled and all I can find is a GitHub issue page. I read it but don't understand whether there's a solution in the tornado.py.
>>>
>>>
>>>
>>> The second problem is that I dont' know how to construct the structure.
>>>
>>> I tried
>>>
>>> cd /var/www/html/visualization/bokeh_apps/
>>>
>>> bokeh serve
>>> --show myapp --port 5100 --host 127.0.0.1:80/visualization/bokeh_apps/
>>> and it returned "invalid port in host value". When I run locally in Python bokeh serve --show myapp, the address is like "localhost:5006/myapp" and doesn't show any structure. Is there some trick to do this? I searched but didn't find anything.
>>>
>>>
>>>
>>> Thanks a lot for your help!
>>>
>>>
>>>
>>> P.S. if Nignx has the solution for these 2 problems, it's still quite unlikely that my supervisor will agree to swtich from Apache...
>>>
>>>
>>> --
>>> 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 bokeh+un...@continuum.io.
>>> To post to this group, send email to bo...@continuum.io.
>>> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0ff064a9-8d71-4a53-a409-05e5c5763fdd%40continuum.io\.
>>> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
>>
>
--
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/151cc948-ff52-405f-b428-528f232add5e%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.