Could not open websocket with bokeh on nginx - nginx

I am trying to use bokeh on a digitalocean droplet, which runs ubuntu 18.04 with LAMP stack and reverse-proxy nginx (set up as described in these tutorials Initial server setup, LAMP setup, nginx as reverse-proxy ).
I used these tutorials (1 and 2) for setting up the bokeh part.
It looks like that it almost works but I get some error messages in the Browser console, of which I do not know how to resolve them.
This is the output in the browser console:
Bokeh: BokehJS not loaded, scheduling load and callback at Date ...
Bokeh: injecting script tag for BokehJS library: /bokeh/static/js/bokeh.min.js?v=547e7d2591695b654def5914eef697fa
Bokeh: injecting script tag for BokehJS library: /bokeh/static/js/bokeh-widgets.min.js?v=423bf6bb32b8def9b7c9df74817506e4
Bokeh: injecting script tag for BokehJS library: /bokeh/static/js/bokeh-tables.min.js?v=5f778b8a005d8538b5b14598ec45fc16
Bokeh: injecting script tag for BokehJS library: /bokeh/static/js/bokeh-gl.min.js?v=be19384f76795da42f52380e7b5fd473
Bokeh: all BokehJS libraries/stylesheets loaded
Bokeh: BokehJS plotting callback run at Date ...
[bokeh] setting log level to: 'info'
Bokeh: all callbacks have finished
Source map error: request failed with status 404
Resource URL: https://my-domain.com/bokeh/static/js/bokeh.min.js?v=547e7d2591695b654def5914eef697fa
Source Map URL: bokeh.min.js.map 2
Source map error: request failed with status 404
Resource URL: https://my-domain.com/bokeh/static/js/bokeh-widgets.min.js?v=423bf6bb32b8def9b7c9df74817506e4
Source Map URL: bokeh-widgets.min.js.map
Source map error: request failed with status 404
Resource URL: https://my-domain.com/bokeh/static/js/bokeh-tables.min.js?v=5f778b8a005d8538b5b14598ec45fc16
Source Map URL: bokeh-tables.min.js.map
Source map error: request failed with status 404
Resource URL: https://my-domain.com/bokeh/static/js/bokeh-gl.min.js?v=be19384f76795da42f52380e7b5fd473
Source Map URL: bokeh-gl.min.js.map
Firefox can’t establish a connection to the server at wss://my-domain.com/bokeh/ws?bokeh-protocol-version=1.0&bokeh-session-id=Zts1wLAtCSZoHUr7Nx3UfIFdUAgGOMFdFA8JfEuDmEzM.
[bokeh] Failed to connect to Bokeh server Error: Could not open websocket
pull_session https://my-domain.com/bokeh/static/js/bokeh.min.js?v=547e7d2591695b654def5914eef697fa:31
[bokeh] Lost websocket 0 connection, 1006 ()
Error: Could not open websocket
[bokeh] Websocket connection 0 disconnected, will not attempt to reconnect
This is part of the nginx conf file:
location / {
include proxy_params;
proxy_pass http://unix:/home/user/myproject/myproject.sock;
}
# reverse proxy to embedded bokeh apps
location /bokeh/ {
proxy_pass http://127.0.0.1:5100;
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;
}
I guess there is something missing in the conf file, but I cannot figure out what.

I checked the nginx log and there are no errors. allow-websocket-origin is set in the script with kws = {'port': 5100, 'prefix': '/bokeh', 'allow_websocket_origin': ['xxx.xxx.xxx.xx']} with the public IP address of my droplet.
Unless you are ultimately connecting with the literal ip address in the URL bar, that won't work. You need to whitelist what is in the HTTP request ORIGIN header, i.e. typically exactly the hostname that you navigate to in the browser

Related

BigblueButton serves only on HTTP not HTTPS

I installed on Ubuntu 16.04, 4 cores, 8Gb RAM. I ran the cerbot command and it returned a congratulatory message that it's successful.
This is my first time installing BigBlueButton. I followed the process and all seemed fine until I tried running it on HTTPS https://live.oltega.com, and it returned
This site can’t be reached
live.oltega.com refused to connect.
Try: Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
when I served the same on HTTP http://live.oltega.com it worked well but displays a blue screen because it can only work on HTTPS. What can I try next?
After obtaining a Let's Encrypt certificate, you should configure the BBB components like Nginx and Freeswith to use HTTPS.
Follow the instructions mentioned here.
The summary is :
1-Configure FreeSWITCH for using SSL
Edit the file /etc/bigbluebutton/nginx/sip.nginx and change the protocol and port on the proxy_pass line as shown bellow
location /ws {
proxy_pass https://203.0.113.1:7443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_read_timeout 6h;
proxy_send_timeout 6h;
client_body_timeout 6h;
send_timeout 6h;
}
2- Configure BigBlueButton to load session via HTTPS
Edit /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties and update the property bigbluebutton.web.serverURL to use HTTPS:
#----------------------------------------------------
# This URL is where the BBB client is accessible. When a user successfully
# enters a name and password, she is redirected here to load the client.
bigbluebutton.web.serverURL=https://bigbluebutton.example.com
Next, edit the file /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties and update the property jnlpUrl and jnlpFile to HTTPS:
streamBaseUrl=rtmp://bigbluebutton.example.com/screenshare
jnlpUrl=https://bigbluebutton.example.com/screenshare
jnlpFile=https://bigbluebutton.example.com/screenshare/screenshare.jnlp
Next, you should do the following command:
$ sudo sed -e 's|http://|https://|g' -i /var/www/bigbluebutton/client/conf/config.xml
Open /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml editing and change:
kurento:
wsUrl: ws://bbb.example.com/bbb-webrtc-sfu
to
kurento:
wsUrl: wss://bbb.example.com/bbb-webrtc-sfu
and also
note:
enabled: true
url: http://bbb.example.com/pad
to
note:
enabled: true
url: https://bbb.example.com/pad
3- Next, modify the creation of recordings so they are served via HTTPS
Edit /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml and change the value for playback_protocol as follows:
playback_protocol: https
4-If you have installed the API demos, edit /var/lib/tomcat7/webapps/demo/bbb_api_conf.jsp and change the value of BigBlueButtonURL use HTTPS.
// This is the URL for the BigBlueButton server
String BigBlueButtonURL = "https://bigbluebutton.example.com/bigbluebutton/";
5-Finally, to apply all of the configuration changes made, you must restart all components of BigBlueButton:
$ sudo bbb-conf --restart

Server side event is not working Kubernetes ingress controller and erred out

We have an API which will create a cluster and wait for the status until it creates and executes a query in database.
We tried this through Ingress and are getting timed-out.
And we have set in ingress rule as below:
nginx.ingress.kubernetes.io/configuration-snippet: |
location / {
proxy_set_header Connection "";
proxy_http_version 1.1;
}
Error:
nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
If we set this it's creating under /data path which is our main API path, and it's not working as expected.
Is there any direct annotation to use server side events?
If we use the above snippet in ingress rule and get this error in controller logs.
Below error Error:
exit status 1
2020/06/26 04:57:22 [emerg] 132#132: location "/" is outside location "/data/" in /tmp/nginx-cfg140739857:11409
nginx: [emerg] location "/" is outside location "/data/" in /tmp/nginx-cfg140739857:11409
nginx: configuration file /tmp/nginx-cfg140739857 test failed.
As the doc suggests, you should never use / for hosting your data from. It should be somewhere in /data/*.
Some directories in any file system should never be used for hosting data from. These include / and root. You should never use these as your document root.
Doing this leaves you open to a request outside of your expected area returning private data.
NEVER DO THIS!!!
server {
root /;
location / {
}
}

How to debug django channels in production (nginx)?

django channels is working on both my local server and in the development server in my production environment; however, I cannot get it to respond in production nor can I get it to work with the following Daphne command (dojos is the project name):
daphne -b 0.0.0.0 -p 8001 dojos.asgi:channel_layer
Here is sample of what happens after the command:
2019-05-08 08:17:18,463 INFO Starting server at tcp:port=8001:interface=0.0.0.0, channel layer dojos.asgi:channel_layer.
2019-05-08 08:17:18,464 INFO HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2019-05-08 08:17:18,464 INFO Using busy-loop synchronous mode on channel layer
2019-05-08 08:17:18,464 INFO Listening on endpoint tcp:port=8001:interface=0.0.0.0
127.0.0.1:57186 - - [08/May/2019:08:17:40] "WSCONNECTING /chat/stream/" - -
127.0.0.1:57186 - - [08/May/2019:08:17:44] "WSDISCONNECT /chat/stream/" - -
127.0.0.1:57190 - - [08/May/2019:08:17:46] "WSCONNECTING /chat/stream/" - -
127.0.0.1:57190 - - [08/May/2019:08:17:50] "WSDISCONNECT /chat/stream/" - -
127.0.0.1:57192 - - [08/May/2019:08:17:52] "WSCONNECTING /chat/stream/" - -
(forever)
Meanwhile on the client side I get the following console info:
websocketbridge.js:121 WebSocket connection to 'wss://www.joinourstory.com/chat/stream/' failed: WebSocket is closed before the connection is established.
Disconnected from chat socket
I have a feeling that the problem is with nginx configuration, so here is my config file server block:
location /chat/stream/ {
proxy_pass http://0.0.0.0:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
}
location /static/ {
root /home/adam/LOCdojos;
}
I made sure that the consumers.py file had this line:
def ws_connect(message):
message.reply_channel.send(dict(accept=True))
I tried installing django debug toolbar w/ the channels panel per question:
Debugging django-channels
but it did not help in the production environment.
I am stuck - what is the next step?
I am also stuck with this kind of problem, but this:
proxy_pass http://0.0.0.0:8001;
looks really weird for me - is it works that way? Maybe:
proxy_pass http://127.0.0.1:8001;

Node Red UI not showing while on reverse proxy nginx

I currently have a setup of node-red running on raspberry pi stretch. the node-red doesnt have any problem when running local.
The raspberry pi is behind a nginx reverse proxy server. whenever being accessed on my domain, flow doesnt show up even any objects on the page. the only thing that is showin is the header bar.
I currently have a flow deployed before hand with some soft of dashboard, the /ui loads fine on the outside. like I said when accessing the admin/user pages, it looks fine. So I am guessing that the fault is in the nginx.
Anybody who has the same setup without problem? would you mind to share your config on nginx. Special thanks.
Node-RED version: v0.18.6
Node.js version: v8.11.2
System: Raspbian - Linux 4.14.34-v7+ arm LE
Nginx version: 1.14.0
Nginx Config:
server {
listen 80;
server_name xx.xx.xx.ph;
location / {
proxy_pass http://localhost:1880;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Chrome browser console error:
blob:http://nberic.mmsu.edu.ph:1880/a74b9da3-2abf-4e9f-95ce-fbfb3573e0de:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
ace.js:1 Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
red.min.js:1 Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
vendor.js:1 Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
ext-language_tools.js:1 Uncaught ReferenceError: ace is not defined
at ext-language_tools.js:1
main.min.js:16 Uncaught ReferenceError: $ is not defined
at main.min.js:16
at main.min.js:16

Rails 5 Action Cable deployment with Nginx, Puma & Redis

I am trying to deploy an Action Cable -enabled-application to a VPS using Capistrano. I am using Puma, Nginx, and Redis (for Cable). After a couple hurdles, I was able to get it working in a local developement environment. I'm using the default in-process /cable URL. But, when I try deploying it to the VPS, I keep getting these two errors in the JS-log:
Establishing connection to host ws://{server-ip}/cable failed.
Connection to host ws://{server-ip}/cable was interrupted while loading the page.
And in my app-specific nginx.error.log I'm getting these messages:
2016/03/10 16:40:34 [info] 14473#0: *22 client 90.27.197.34 closed keepalive connection
Turning on ActionCable.startDebugging() in the JS-prompt shows nothing of interest. Just ConnectionMonitor trying to reopen the connection indefinitely. I'm also getting a load of 301: Moved permanently -requests for /cable in my network monitor.
Things I've tried:
Using the async adapter instead of Redis. (This is what is used in the developement env)
Adding something like this to my /etc/nginx/sites-enabled/{app-name}:
location /cable/ {
proxy_pass http://puma;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
Setting Rails.application.config.action_cable.allowed_request_origins to the proper host (tried "http://{server-ip}" and "ws://{server-ip}")
Turning on Rails.application.config.action_cable.disable_request_forgery_protection
No luck. What is causing the issue?
$ rails -v
Rails 5.0.0.beta3
Please inform me of any additional details that may be useful.
Finally, I got it working! I've been trying various things for about a week...
The 301-redirects were caused by nginx actually trying to redirect the browser to /cable/ instead of /cable. This is because I had specified /cable/ instead of /cable in the location stanza! I got the idea from this answer.

Resources