Asking a guide how to setup ngrok on HA

Setup HA over Orange Pi One, version core-2021.8.1. Already added as add on the ngrok client. But i am having trouble how to make ngrok generate tunnels. I used ngrok on other projects, but I don’t know how to configure ngrok client to generate tunnels. Anyone can guide a newbie how to setup my ngrok on HA? Here are is my ngrok config:

log_level: info
auth_token: *************authcode**************************
region: ap
tunnels:
  - name: hass
    proto: tls
    addr: 8321
  - name: lets-encrypt
    proto: http
    addr: 80
    bind_tls: false

and found these in the logs:
TLS tunnel for the account '[email protected]'.\nThis account is on the 'Free' plan.\n\nUpgrade to Pro or Business: https://dashboard.ngrok.com/billing/plan\r\n\r\nERR_NGROK_312\r\n"
Only Pro & Business plans may bind TLS tunnels.
Failed to bind a TLS tunnel for the account '[email protected]'.
This account is on the 'Free' plan.

Anyone can point me to the right direction how to set it up without the pro account? Thanks!

If you are using free Ngrok account, use this configuration-

log_level: info
auth_token: ## REDACTED ##
region: ap #Options: us, eu, ap, au, sa, in
tunnels:
  - name: hass
    proto: http
    addr: 8123
    inspect: false
    bind_tls: true

Next, Start the addon and check the logs. Did you see any errors? If not, on the addon page, click Open Web UI. This should take you to your Home Assistant External URL.

Please note that if you restart the addon or restart Home Assistant Host, the External URL will change.

To be notified regarding URL changes, first, you need to create a URL sensor by adding this line to your configuration.yaml-

sensor:
  - platform: rest
    resource: http://localhost:4040/api/tunnels/hass
    name: Home Assistant URL
    value_template: '{{ value_json.public_url }}'

Now, you will have a URL sensor in your lovelace dashboard. Then, it’s time to automate notification if the URL changes.

trigger:
  - platform: state
    entity_id: sensor.home_assistant_url
  - platform: homeassistant
    event: start

condition:
  - condition: template
    value_template: >-
      {{ states('sensor.home_assistant_url') != 'unavailable' }}
  - condition: template
    value_template: >-
      {{ trigger.to_state.state != trigger.from_state.state }}

action:
  - service: notify.quarks_telegram
    data:
      message: >-
        ALERT! Your public address has changed to: {{ states('sensor.home_assistant_url') }}

@Quarks I forget that you also need to setup reverse proxy (if your HA version is 2021.7+) by adding this in your configuration.yaml-

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24
3 Likes

Trying it now @ardysusilo . Will update my results. Thanks a lot!

Got the ngrok add on working now, and a tunnel is already generated. but my ngrok io url gives me a 400 bad request.

This is my ngrok config now:

log_level: info
auth_token: *************auth token**************
region: ap
tunnels:
  - name: hass
    proto: http
    addr: 8321
    inspect: false
    bind_tls: false

i made addr: as 8321 since my HA port i changed it from 8123 to 8321 to avoid port scanners. bind_tls: false since my HA server is only using http:

is there anything in my config giving me my ngrok io url gives a 400 bad request?

Gotcha! This is not in my configuration.yaml, will check it out now.

everything working well right now! Thanks a lot @ardysusilo !!!

Thank you @ardysusilo for the complete guide! I recently switched ISPs to one that uses CGNAT and doesn’t even offer a public/static IP as an option. I’m only aware of CGNAT after switching to this provider and previously I was fine with just a DuckDNS setup because my previous ISP provides me with a static IP.

I was wondering if it’s possible to feed the URL into DuckDNS. I noticed in the documentation that if you enter a URL that outputs your public IP address like https://api.ipify.org in the configuration, that IP address would be updated to DuckDNS’ “current IP”.

I tried adding

ipv4: http://localhost:4040/api/tunnels/hass

to the configuration but it didn’t work, most likely because it outputs an URL, not an IP address. Is there a way for DuckDNS to get the IP address from NGROK?

I don’t think you can. I personally have not tried it myself but I’ve read somewhere else. I don’t think the IP changes is a problem as it changes ONLY when you reboot Home Assistant OS or restart the add-on which rarely happen in my case.

In the case that it happens, you can setup automation to notify you via Telegram as I have described in my earlier post. Retrieving the new IP address and copy pasting it to Home Assistant App takes less than a minute.

If you think it is such of inconvenience, you can use either ZeroTier or Tailscale. Both options require you to connect to the VPN before accessing your local Home Assistant server.

Unfortunately, even restoring old configurations no longer allows any NGROK function !! someone still works ??

I no longer use this Ngrok add-on. I recommend you check this Cloudflared add-on made by Tobias-