# Webcam / IFrame problem with LAN / WAN enviroment

**URL:** <https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584>\
**Category:** General\
**Created:** [3 March 2020 20:50 UTC](https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584 "2020-03-03T20:50:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [3 March 2020 20:50 UTC](https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584/1 "2020-03-03T20:50:24Z")

</div>

Hiho my friends. I ve a problem with iframes of my webcams when changing the network enviroment.  
I forwarded my ports of the node red user interface to make it accessable from everywhere in the www.  
I ve some webcams in my menu having their own webinterface. I used a iframe node and linked to these webinterface. ([shot1](http://puu.sh/FgQBJ/052f6cadfd.png)) Everything works fine as long as I am using my ui from my lan. If I call my ui from www the iframes will not work because they link to an internal ip adress witch is not access able from there.... I could change the ip to an external one but that would force the interface allways to route all data through the www. this would cause a delay, traffic and would bound my node red ui to a working www (at least the webcams). Any solutions for making the iframe ui link dynamic or something else that could help ?  
thanx !

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [4 March 2020 08:21 UTC](https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584/2 "2020-03-04T08:21:49Z")

</div>

> I forwarded my ports of the node red user interface to make it accessable from everywhere in the www.

This is not recommended, unless you know how to secure it properly.

You might want to read this

> [@warning Malware Infecting unsecured Node-RED servers](https://discourse.nodered.org/t/malware-infecting-unsecured-node-red-servers/3460):
>
> There have been a growing number of reports of unsecured instances of Node-RED having a crypto-mining flow automatically deployed on them. This is a result of exposing Node-RED on the internet without having applied any security - something we strongly advise against. If you have been affected, the only safe option is to wipe and reinstall the server/device running Node-RED. You must also ensure you properly secure Node-RED. At a bare minimum, you should enable adminAuth as described in the [d…](https://nodered.org/docs/security)

---

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [4 March 2020 12:54 UTC](https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584/3 "2020-03-04T12:54:06Z")

</div>

thanx, but of course I secured node red by using adminAuth, ports \> 1024. (like the article tells), I ve backups.... https will follow.

.... but the problem still remains. can anybody help me on that ?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [4 March 2020 13:47 UTC](https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584/4 "2020-03-04T13:47:40Z")

</div>

Rereading your topic: your problem will remain unless you open all your cams up to the internet too.  
Possible solution: use vpn.

---

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [6 March 2020 13:49 UTC](https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584/5 "2020-03-06T13:49:08Z")

</div>

Solution goes like this:

- webcam 1 interface is reachable at 192.168.0.55:8055 in local network and [myhome.ddns.net:8055](http://myhome.ddns.net:8055) in www
- Create an new group assigned with a template node and use the browser debugging tools to search for a unique indentfier. in my case "Webcam\_Test\_1\_Test\_Aufbau\_cards md-card"  
([shot](http://puu.sh/FhK8w/6b101cde3a.png))
- put my code into the template node. the code will basicly

```auto
<script>
(function() {
    const external = 'myhome.ddns.net';
    let isLocal = window.location.hostname !== external;

    let cam1 = (isLocal ? '192.168.0.55' : external) + ':8055';
    let cam2 = (isLocal ? '192.168.0.56' : external) + ':8056';
    
    let iframe = document.createElement('iframe');
    iframe.src = 'http://' + cam1;
    iframe.style.height = '400px';
    //iframe.style.border = '2px solid red';
    
    document.querySelector('#Webcam_Test_1_Test_Aufbau_cards md-card').appendChild(iframe);
})();    
</script>

```

The script will replace the iFrame url depending from the variable "window.location.hostname" to identify if the call was made from [myhome.ddns.net](http://myhome.ddns.net) or if not local....

Some words to VPN solution: Installing a VPN on my system will cost resources which I need for other stuff. the 1GB RAM of my raspi is on the limit and switching to raspi 4 will be an efford that I ve no time for atm.

As always sorry for my bad english 🙂

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [6 March 2020 17:41 UTC](https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584/6 "2020-03-06T17:41:36Z")

</div>

> I ve no time for atm.

I hope your time is worth more than the security of your home.

---

<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:** [20 March 2020 17:49 UTC](https://discourse.nodered.org/t/webcam-iframe-problem-with-lan-wan-enviroment/22584/7 "2020-03-20T17:49:34Z")

</div>

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