I have a GUI in GTK that I am running in my web browser with GTK's built in HTML5 backend, Broadway. https://developer.gnome.org/gtk3/stable/gtk-broadway.html I can view it on port 8081 like this:
broadwayd :1
and then any GUI I make in GTK will show up in my browser if I use localhost:8081 as my URL. Big picture, I am going to spawn this GUI in a browser using Jupyterhub. Jupyterhub uses Node's configurable-http-proxy package (which is just a wrapper around node-http-proxy) to create a reverse proxy so that the GUI can be accessed at my.ip.address/user/paul. When I try to do this, some of the HTML seems to get through (I see broadway listed on my browser tab), but the firefox console tells me that there is a 400 websocket error, and I can never make a GUI appear.
I have gotten this working before with NGINX in a reverse proxy. Here is a working configuration that will take the broadway server on port 8081 and let me view it in my browser at port 8015:
events {}
http {
upstream websocket {
server 127.0.0.1:8081;
}
server {
listen 8015;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}
I am not sure how to make identical Node code to do this. This is my attempt (which gives the 400 websocket error):
var util = require('util'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var proxy = new httpProxy.createProxyServer({
ws: true
});
var proxyServer = http.createServer();
proxyServer.on('request', function (req,response) {
console.log('received a request');
proxy.web(req, response , {target: 'http://0.0.0.0:8081'});
});
proxyServer.on('upgrade', function (req, socket,head) {
console.log('received a ws request');
proxy.ws(req, socket, head,{target: 'http://0.0.0.0:8081'});
});
proxyServer.listen(8015);
I think that I do not understand the "proxy pass" equivalent in Node. Any help would be appreciated! Thanks!