Use NodeRED in an iframe behind a proxy

My NodeRed instance runs on a pc (currently ubuntu 20.04) behind a nginx reverse proxy. I installed it today with the install script, so it should be the latest stable version (i guess). Nginx config, proxy settings taken from https://discourse.nodered.org/t/node-red-server-with-nginx-reverse-proxy-howto-guide/27397:

server {
	listen 80 default_server;
	listen [::]:80 default_server;
	server_name _;

	location / {
		proxy_pass http://127.0.0.1:1880;
		proxy_http_version  1.1;
		proxy_cache_bypass  $http_upgrade;
		proxy_set_header Upgrade $http_upgrade;   
		proxy_set_header Connection "upgrade";
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_set_header X-Forwarded-Host $host;
		proxy_set_header X-Forwarded-Port $server_port;
	}
}

This works great so far with direct access. Though, I want to use another pc as proxy server for this one (ubuntu 20.04 as well), and I use nginx with almost identical settings:

server {
	listen 80;
	listen [::]:80;

	server_name s1.hiveserver;

	location / {
		proxy_pass       http://10.0.0.2;
		proxy_http_version  1.1;
		proxy_cache_bypass  $http_upgrade;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_set_header X-Forwarded-Host $host;
		proxy_set_header X-Forwarded-Port $server_port;
	}
}

This works great as well in conjuction with my local hosts file:

<snip>
192.168.57.10	hiveserver
192.168.57.10	s1.hiveserver

with 192.168.57.10 being the IP of the proxy.
As long as i access s1.hiveserver in the browser directly, it works perfectly fine. But if I serve a simple website from the proxy itself (http://hiveserver) containing an iframe with the s1.hiveserver site, the nodered header loads, but the rest of the windows stays gray.
This is the site the proxy is serving:

<!DOCTYPE html>
<html>
	<head>
		<title>Server frontend page</title>
	</head>
	<body>
		<iframe src="http://s1.hiveserver" width="1500px" height="800px" style="margin: 50px" />
	</body>
</html>

And the result:


When loading the page, the js scripts get loaded with status 200, but the JS console shows an error:

jQuery.Deferred exception: Cannot read property 'getItem' of null TypeError: Cannot read property 'getItem' of null
    at Object.init (http://s1.hiveserver/red/red.min.js:16:15443)
    at Object.init (http://s1.hiveserver/red/red.min.js:16:14844)
    at HTMLDocument.<anonymous> (http://s1.hiveserver/red/main.min.js:16:161)
    at e (http://s1.hiveserver/vendor/vendor.js:2:30005)
    at t (http://s1.hiveserver/vendor/vendor.js:2:30307) undefined
vendor.js:2 Uncaught TypeError: Cannot read property 'getItem' of null
    at Object.init (red.min.js:16)
    at Object.init (red.min.js:16)
    at HTMLDocument.<anonymous> (main.min.js:16)
    at e (vendor.js:2)
    at t (vendor.js:2)

The error is 100% reproducable, even after reboot.
Unfortunately the error is so generic and seems very common with some Android web widget, I could not get any help from googling the error.
Has anybody an idea how to approach this? Please ask if something I wrote is unclear.

[EDIT]: Surprisingly, the error does not occur in the firefox browser, but only in the brave browser (chromium engine).

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.