Ok, so I have fixed the websocket issue.
Some context, I run node-red as embedded in an express server. All my express routes start with /api, so I have to config my settings of Node-RED to reflect that.
This is my settings. Notice the httpAdminRoot and httpNodeRoot.
const settings = {
httpAdminRoot: '/api/red/admin/',
httpNodeRoot: '/api/red/',
userDir: `${os.homedir()}/.nodered/`,
flowFile: './flows/flows.json',
flowFilePretty: true,
functionGlobalContext: {
lodash: require('lodash'),
mongodb: require('mongodb'),
},
editorTheme: {
header: {
title: 'Node-RED',
image: null,
},
},
};
RED.init(server, settings);
this.app.use(settings.httpAdminRoot, RED.httpAdmin);
this.app.use(settings.httpNodeRoot, RED.httpNode);
RED.start();
So in my nginx config, I took the code from Using NGINX as a WebSocket Proxy and change my config on the remote server to this.
location /api/ {
proxy_pass http://localhost:3000/api/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
Now I can access the node-red client at http://localhost:3000/api/red/admin/
Hope this help.