Hi.
I'm trying to put Node-red and Grafana behind a reverse proxy with nodejs express and http-proxy-middleware. My situation:
I have a 4G router that sits between a linux machine running Node-red and Grafana and the WAN net.
I portforward :8080 -> LAN_IP:9000.
Grafana listens on: 3000. http
Node-red listens on: 1882. http
My proxymiddleware.js file:
const express = require('express')
const { createProxyMiddleware } = require('http-proxy-middleware')
const applicationPort = 9000
const app = express()
// redirect for grafana
app.use('/grafana/', createProxyMiddleware({
target: 'http://localhost:3000',
changeOrigin: true
}))
// redirect for node-red dashboard
app.use('/dashboard/', createProxyMiddleware({
target: 'http://localhost:1882',
changeOrigin: true
}))
// redirect for node-red editor
app.use('/editor/', createProxyMiddleware({
target: 'http://localhost:1882',
changeOrigin: true,
pathRewrite: {
'^/editor': ''
}
}));
app.listen(applicationPort, () => {
console.log(`Reverse proxy listening on ${applicationPort}`)
})
Grafana.ini file:
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
server_from_sub_path = true
Node-red settings.js file:
httpAdminRoot: '/editor'
httpNodeRoot: '/dashboard'
This works like a charm with Grafana.
WAN:IP:8080/grafana
But with Node-red
WAN_IP:8080/editor or /dashboard
I get this error:
Error occurred while trying to proxy: WAN_IP:8080/
I'm specifically targeting 'http://localhost:1882'. Why is it complaining about WAN_IP?
Am I doing this wrong? Some online resources and AI told me to do it this way.
I have tried any number of different configurations of this.
Best regards
Steffen