Iframe - Access from external

Hi all

the newly released feature of iframe embedding, I cant access it externally (from work for example). I have couple of web apps running locally on raspberry pi 3 and their ports are not exposed to external.

Does it mean I have to expose those ports as well for it to work? I have tested, iframe works when at home but not working outside home.

Thanks

Short answer is yes. :grinning:

1 Like

haha i already knew the answer. dang!
is there a way to just opening ports to HA not the entire world?

Not that I’m aware of. Also keep in mind that if you’re running an ssl setup, your iframe URL will need to be HTTPS or you may get errors or even a blank page.

1 Like

regardless, this iframe still helpful even if only on local network. too bad it doesnt allow opening on another window/tab (this should remove the need for the feature of internal links)

If you expose HASS directly at the moment then consider using something like nginx to reverse proxy to it.

You can then reverse proxy additional pages to your internal systems, i.e /some_iframe/server/ grabs content from your Pi3, will then work from outside.

1 Like

im not too familiar with nginx reverse proxy (one of the things i need to learn) :slight_smile:

I’m also faced with this issue, trying to run Grafana alongside HA, so I can access it in an iframe panel.

I’m using nginx and have SSL, the locations in my nginx config are like this:

...
location /proxy/grafana/ {
    proxy_pass http://localhost:3000;
    proxy_set_header Host $host;
    proxy_redirect http:// https://;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
}

location / {
    proxy_pass http://localhost:8123;
    proxy_set_header Host $host;
    proxy_redirect http:// https://;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
}
...

However, when I go to /proxy/grafana/ I just get the HA interface and it alters the URI to /proxy. I guess this is something to do with its html5-app’iness, so URLs get overridden somehow. Has anyone gotten this to work properly?

You need to use iframe with https link to grafana.
My setup is as follows:

  • nginx:
location / {
    proxy_pass http://localhost:<ha_port>/;
    proxy_set_header Host $host;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

location /api/websocket {
    proxy_pass http://localhost:<ha_port>/api/websocket;
    proxy_set_header Host $host;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}
  • Grafana is configured to work on https

  • Home Assistant configuration for Grafana:

panel_iframe:
  grafana:
    title: 'Grafana'
    url: 'https://<domain_name>:3000'

I am using Grafana as hassio add-ons,
I would like to run grafana from internet without forwarding port in router,
Please guide me how to do with nginx addon!?

Maybe it can be made to work as described here: How to deal with non-SSL Panel iframe pages inside SSL Hass.io environment?

Question…

Running iframe locally and it works.
Running it through the cloud service and the page doesn’t load.

I need my router config page to load up when I’m not in my summer house.

Someone who knows what to do?

//Martin

Found the solution on my side to have all displayed correctly using docker (homeassistant, glances, tasmoadmin, nodered and much more…)

Most important, I used Lets’Encrypt docker image to control how my machine is exposed and in a secure way.

1. Setup LetsEncrypt (docker-compose v3.5)

  letsencrypt:
    container_name: 'letsencrypt'
    image: linuxserver/letsencrypt
    restart: always
    cap_add:
      - NET_ADMIN
    volumes:
      - [you path]:/config
      - /etc/localtime:/etc/localtime:ro
    environment:
      - PGID=1004
      - PUID=1000
      - EMAIL=# your email address
      - URL=# main url -> yoursubdomain.duckdns.org
      - VALIDATION=duckdns
      - SUBDOMAINS=wildcard
      - DUCKDNSTOKEN=# your token
      - TZ=Europe/Zurich
    ports:
      - "443:443"
      - "80:80"
    #Uncomment below if you use WatchTower
    #labels:
    #  - com.centurylinklabs.watchtower.enable=true

Once ready, modify the [yourpath]/nginx/proxy-confs/*.conf files

2. Setup for Glances: (sample)

Note : I do created a numerical subname, difficult to remember because I will not connect directly but your it within Home Assistant only. Something like an 6 or 8 digits “34355322” or “de334sd2”…

# make sure that your dns has a cname set for glances and that your glances container is not using a base url

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name [the name you want but to not expose it, use a 6 or 8 digits name like [34322332].*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    # enable for ldap auth, fill in ldap details in ldap.conf
    #include /config/nginx/ldap.conf;

    location / {
        # enable the next two lines for http auth
        #auth_basic "Restricted";
        #auth_basic_user_file /config/nginx/.htpasswd;

        # enable the next two lines for ldap auth
        #auth_request /auth;
        #error_page 401 =200 /login;

        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_glances [your local dns name or ip];
        proxy_pass http://$upstream_glances:61208;
    }
}

Then, in HomeAssistant within your iFrame configuration :

docker_glances:
  title: "Glances - Docker"
  url: "https://[the subname you choosed].manoir.duckdns.org"
  icon: mdi:docker

Note : Must be https

You’re done once rebooted.

PS : If you have issue setting up the letsencrypt docker image, check the website and follow the guidelines.

1 Like

I am using Grafana installed deb files
I would like to run grafana from internet and locally from homeassistant.
i am able to get it working from internet as well as local ip
but if i embedded it using panel_iframe for domain it works with home-assitant , i am unable to get it when i open homeassistant on my local ip.
Please guide on how can i reun grafana from hassio panel_iframe locally as well as from domain.
thanks

There is an integration that solves this problem.
I just tested it and for now it is working.
Many thanks to @lovelylain

1 Like

that is a great integration. works for my local only frigate.
i tried with different app, but no success so far, likely just the app configuration itself.