2024年11月24日星期日 下午9:25:57

How to Install Frp on Home Assistant Operating System(HassOs on Raspberry Pi) Step by Step

2 年 前
#30 引用
case 1:Home Assistant是树莓派安装了官方的系统HassOs

Home Assistant官方的系统hassos较为封闭,因为它意在让用户免去搭建homeassistant的繁琐,不用去理会复杂的linux系统,而是直接去使用homeassistant。

frp

即便frp是免安装的,在hassos上运行也令人头疼,因为必须要满足每次开机能够让frp自动运行。而我们平常用ssh工具登录的,其实是hassos的一个容器,每次关机这个容器都要被销毁,开机的时候再被重新建立。所以在这个容器手动安装运行的软件,一旦重启树莓派,便都没了。

当然也可以获取hassos系统的超级权限,从而可以登陆到hassos系统中去,而不是容器中。但是因为hassos是精简过的,所以一时半会还摸不透它属于哪个派系,干脆放弃。

下面的这三个条件让在hassos开机自动运行frp:
1,放homeassistant配置文件的目录/config,重启是不会消失的。
2,homeassistant有一个组件叫shell_command,利用它可以执行一些命令。
3,frp是免安装的。

https://blog.csdn.net/zuobianfy/article/details/111712872


case 2:

环境
公网IP服务器(IP:6.6.6.6)
本地服务器(IP:192.168.1.100)
域名(havcs.ljr.im)
期待效果:访问https://havcs.ljr.im:8443,相当于穿透访问http://192.168.1.100:8123
准备,网上教程很多不详细赘述
域名供应商将添加havcs.ljr.im解析到6.6.6.6的A记录
准备域名ssl证书
公网IP服务器安装frp服务端
本地安装frp客户端(可安装在192.168.1.100上)
本地服务器安装Nginx(可选,监听端口443)和Home Assistant(监听端口8123)

ha的web界面有两种协议,http和websocket,看了frp项目的https2http插件只能过https协议,不能过wss协议,所以想一步到位搞定全站对内http,对外https+外网穿透,用frp估计没戏


Useful links

1.

https://github.com/steplov/hassio-frp-client

Homeassistant利用FRP实现外网访问
https://netheroone.cn/archives/800a8ecd.html

0
2 年 前
#2456 引用
case 2:Install Frp client on  Raspberry Pi 3b+ Step by Step

Add a frpc.ini configuration file to /share/frp directory  on Raspberry Pi
Run frps on remote server with public ip
Start Hass

Step 1:CPU
arch


root@raspberrypi:~# arch
armv7l



If it’s ARMv3 to v7: You are running a 32 bits operating system
If it’s ARMv8 or aarch64: You are on a 64 bits operating system


case $build_arch in
        "aarch64")
            machine="arm64"
        ;;
        "amd64")
            machine="amd64"
        ;;
        "armhf")
            machine="arm"
        ;;
        "armv7")
            machine="arm"
        ;;
        "i386")
            machine="386"
        ;;
    esac;


more detail:

查看树莓派 | Linux 系统是多少位
https://www.msly.cn/boards/topic/57/installing-home-assistant-core-on-raspberry-pi-3b#1205


Step 2: go to https://github.com/fatedier/frp/releases



Cpu is arm
operating system 32 bits

choice :frp_0.38.0_linux_arm.tar.gz
tar


Step 3:Download and Install



wget https://github.com/fatedier/frp/releases/download/v0.38.0/frp_0.38.0_linux_arm.tar.gz
tar xzvf frp_0.38.0_linux_arm.tar.gz

mv ./frp_0.38.0_linux_arm  /usr/local/frp



update 20221212


wget https://github.com/fatedier/frp/releases/download/v0.45.0/frp_0.45.0_linux_arm.tar.gz

tar xzvf frp_0.45.0_linux_arm.tar.gz

mv ./frp_0.45.0_linux_arm/  /usr/local/frp






Step test frpc run ok?

cd /usr/local/frp
./frps --help



/usr/local/frp/frpc -c /usr/local/frp/frpc.ini



Step 3:
cp /usr/local/frp/systemd/frpc.service /etc/systemd/system

vi /etc/systemd/system/frpc.service

0
2 年 前
#2458 引用
Home Assistant Remote access 400: Bad Request

1. cloudflare+nginx+frp + Home assisant web server
2.外网https,内网http,走的是frp内网穿透方案.


visit:https://homeassisant.msly.cn/

output


400: Bad Request



With the latest update of home assistant v2021.7.0 I started getting “400 Bad Request” error when I tried to access HA via my external http/https address. I could still access home assistant without error via the local IP address.

Offcial http documentation Reference:https://www.home-assistant.io/integrations/http/

Step 1:view log

#hass -v

or

http://192.168.101.50:8123/config/logs

log message as follow:



2022-03-16 23:11:47 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from 127.0.0.1, but your HTTP integration is not set-up for reverse proxies





http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1      # Add the IP address of the proxy server
    - 127.0.0.0/24  # You may also provide the subnet mask
  
0
2 年 前
#2459 引用
[homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 127.0.0.1


2022-03-16 23:14:36 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 127.0.0.1






http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1      # Add the IP address of the proxy server
    - 127.0.0.0/24  # You may also provide the subnet mask
    - 192.168.101.50      # Add the IP address of the proxy server
    - 192.168.101.0/24  # You may also provide the subnet mask


other


#log reported ipv4
  - 162.158.159.139
  - 172.69.55.59
  - 141.101.76.195
  - 141.101.98.91
  - 141.101.99.102
  - 141.101.105.87
  - 141.101.105.99
#cloudflare ipv4
  - 103.21.244.0/22
  - 103.22.200.0/22
  - 103.31.4.0/22
  - 104.16.0.0/13
  - 104.24.0.0/14
  - 108.162.192.0/18
  - 131.0.72.0/22
  - 141.101.64.0/18
  - 162.158.0.0/15
  - 172.64.0.0/13
  - 173.245.48.0/20
  - 188.114.96.0/20
  - 190.93.240.0/20
  - 197.234.240.0/22
  - 198.41.128.0/17
#cloudflare ipv6
  - 2400:cb00::/32
  - 2606:4700::/32
  - 2803:f800::/32
  - 2405:b500::/32
  - 2405:8100::/32
  - 2a06:98c0::/29
  - 2c0f:f248::/32
0
2 年 前
#2460 引用
homeassistant.components.http.ban] Login attempt or request with invalid authentication



2022-03-17 00:13:14 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 172.70.214.165 (172.70.214.165). (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36)




1.如果是用的Nginx Proxy Manager,需要打开Websockets Support。
Nginx反代配置中的以下几条:
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

2.chrome

press F12


Request URL: https://homeassisant.msly.cn/auth/token
Request Method: POST
Status Code: 400
0
2 年 前
#3456 引用
POST https://ha.usdotnet.com/auth/token 400 (Bad Request)





0
2 年 前
#3464 引用
Nginx 设置

nginx -v
nginx version: nginx/1.14.0 (Ubuntu)

因为 HomeAssistant 采用了 WebSocket 技术,所以除了静态页面之外,其余的操作都需要使用 WebSocket。所以需要在 Nginx 代理转发的时候也配置好 WebSocket。
0
2 年 前
#3467 引用
frp client config for hass in /share/frp/frpc.ini


# [common] is integral section
[common]
server_addr = <server's ip address>
server_port = 7000

# console or real logFile path like ./frpc.log
log_file = /share/frp/frpc.log

# for authentication
token = sometoken

# set admin address for control frpc's action by http api such as reload
admin_addr = 0.0.0.0
admin_port = 7500
admin_user = admin
admin_pwd = admin

heartbeat_interval = 30
heartbeat_timeout = 90

[homeassistant]
type = http
# home assistant port, usually 812
local_port = 8123
# custom domain, used locally, should much the domain from nginx config
custom_domains = frps123home.hidden


come from:https://github.com/steplov/hassio-frp-client


check  frpc.service run ok


root@raspberrypi:~# sudo systemctl status frpc.service
● frpc.service - Frp Client Service
     Loaded: loaded (/etc/systemd/system/frpc.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-04-04 01:05:16 CST; 1h 47min ago
   Main PID: 765 (frpc)
      Tasks: 6 (limit: 2200)
     Memory: 4.0M
        CPU: 4.236s
     CGroup: /system.slice/frpc.service
             └─765 /usr/local/frp/frpc -c /usr/local/frp/frpc.ini



check frpc.service's log run ok


root@raspberrypi:~# sudo journalctl -fu frpc.service
-- Journal begins at Fri 2016-11-04 01:16:42 CST. --
4月 04 01:05:11 raspberrypi systemd[1]: frpc.service: Main process exited, code=exited, status=1/FAILURE
4月 04 01:05:11 raspberrypi systemd[1]: frpc.service: Failed with result 'exit-code'.
4月 04 01:05:16 raspberrypi systemd[1]: frpc.service: Scheduled restart job, restart counter is at 2.
4月 04 01:05:16 raspberrypi systemd[1]: Stopped Frp Client Service.
4月 04 01:05:16 raspberrypi systemd[1]: Started Frp Client Service.
4月 04 02:52:59 raspberrypi systemd[1]: Stopping Frp Client Service...
4月 04 02:52:59 raspberrypi systemd[1]: frpc.service: Succeeded.
4月 04 02:52:59 raspberrypi systemd[1]: Stopped Frp Client Service.
4月 04 02:52:59 raspberrypi systemd[1]: frpc.service: Consumed 4.264s CPU time.

0
2 年 前
#3678 引用


sudo systemctl daemon-reload
sudo systemctl enable frpc.service
sudo systemctl start frpc.service
sudo systemctl restart frpc.service
sudo systemctl stop frpc.service
sudo systemctl status frpc.service

sudo journalctl -fu frpc.service --since today
0
2 年 前
#3679 引用
Configure frp client on pi



root@raspberrypi:~# sudo systemctl status frpc.service
● frpc.service - Frp Client Service
     Loaded: loaded (/etc/systemd/system/frpc.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-11-26 03:34:10 CST; 1 day 4h ago
   Main PID: 426 (frpc)
      Tasks: 7 (limit: 2200)
     Memory: 16.0M
        CPU: 2min 10.539s
     CGroup: /system.slice/frpc.service
             └─426 /usr/local/frp/frpc -c /usr/local/frp/frpc.ini






https://bbs.hassbian.com/forum.php?mod=viewthread&tid=6085&extra=page%3D1&page=5&mobile=2
0