# Use NodeRED in an iframe behind a proxy

**URL:** https://discourse.nodered.org/t/use-nodered-in-an-iframe-behind-a-proxy/32505
**Category:** General
**Created:** [6 September 2020 11:24 UTC](https://discourse.nodered.org/t/use-nodered-in-an-iframe-behind-a-proxy/32505 "2020-09-06T11:24:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zbrause](https://avatars.discourse-cdn.com/v4/letter/z/67e7ee/32.png) [@zbrause](https://discourse.nodered.org/u/zbrause)
#### Post date: [6 September 2020 11:24 UTC](https://discourse.nodered.org/t/use-nodered-in-an-iframe-behind-a-proxy/32505/1 "2020-09-06T11:24:56Z")

</div>

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](https://discourse.nodered.org/t/node-red-server-with-nginx-reverse-proxy-howto-guide/27397):

```auto
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:

```auto
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:

```auto
<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](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:

```auto
<!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:

 ![nodered_error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/40f1527bd6029bbbd59ebfb86ff23217044cac33.png)  
When loading the page, the js scripts get loaded with status 200, but the JS console shows an error:

```auto
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).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [5 November 2020 11:25 UTC](https://discourse.nodered.org/t/use-nodered-in-an-iframe-behind-a-proxy/32505/2 "2020-11-05T11:25:02Z")

</div>

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