一开始用宝塔默认的方法反代,发现SSH链接不能用,以为是服务器配置问题。 直到今天折腾边缘节点发现也不能用,才反应过来是ws的问题。
只要在宝塔反代的默认配置里加上这3句即可,和HomeAssistant反代一样。
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
#PROXY-START/
location ^~ /
{
proxy_pass http://127.0.0.1:6551;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
set $static_filekx89Dykh 0;
if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
{
set $static_filekx89Dykh 1;
expires 12h;
}
if ( $static_filekx89Dykh = 0 )
{
add_header Cache-Control no-cache;
}
}
#PROXY-END/