暂时不需要了,常规的打洞只适用于http协议或者端口,homeassistant升级带了websocket协议,走http没法搞了,直接走了tcp穿透,本地无需nginx了,需要域名形式访问的话可以在穿透服务端配置Nginx
homeassistant nginx配置
先修改homeassistant的configuration.yaml
http:
server_port: 8123
cors_allowed_origins:
- https://www.home-assistant.io
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
- ::1
- 192.168.12.0/24
ip_ban_enabled: true
login_attempts_threshold: 5
Nginx 配置
注意新增了webdocket
upstream homeassistant {
server 127.0.0.1:8123;
}
## WebSocket connection depending on the variable.$http_upgrade
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
#....
location / {
proxy_pass http://homeassistant;
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;
}
}
评论区