【Home Assistant】ngrok 内网穿透

本文详细介绍了如何从官网下载并配置Ngrok,实现HomeAssistant的内网穿透,包括设置token、创建代理、配置HTTP白名单。重点在于解决400错误并确保在外网访问HomeAssistant的步骤。
摘要由CSDN通过智能技术生成

1.ngrok 官网下载安装

https://ngrok.com/
官网已经有说明,使用很简单
在这里插入图片描述

解压后,配置token

ngrok config add-authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

执行代理

Home Assistant 内网地址为 192.168.2.9:8123

ngrok http 192.168.2.9:8123

会有以下信息

ngrok                                                                                                                  (Ctrl+C to quit)
                                                                                                                                       
Join us in the ngrok community @ https://ngrok.com/slack                                                                               
                                                                                                                                       
Session Status                online                                                                                                   
Account                       xxxx@gmail.com (Plan: Free)                                                                       
Version                       3.0.6                                                                                                    
Region                        Asia Pacific (ap)                                                                                        
Latency                       -                                                                                                        
Web Interface                 http://127.0.0.1:4040                                                                                    
Forwarding                    https://a418-16-163-246-9.ap.ngrok.io -> http://192.168.2.9:8123                                           
                                                                                                                                       
Connections                   ttl     opn     rt1     rt5     p50     p90                                                              
                              0       0       0.00    0.00    0.00    0.00     

访问 https://a418-16-163-246-9.ap.ngrok.io 即可访问到内网 Home Assistant
这时候访问,会出现 400 Bad Request,需要配置Home Assistant

2.配置 Home Assistant 代理白名单

修改 configuration.yaml 文件,增加如下内容

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 18.141.129.0/24
    - 192.168.2.0/24
    - 127.0.0.1

18.141.129.0/24 是ngrok服务器ip,下边为内网,现在就可以在外网访问了

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值