本帖最后由 姚远 于 2022-8-11 13:01 编辑
nginx反代,就是一个路由,hass论坛有经典配置,抄过来就行了。还有啊,nginx已经路由了,内部应用就是在内网的应用方式进行配置。所以,configuration.yaml中,不要配置http了,按照内网配置就可以了
我的nginx 配置文件,外网访问的时候 https://hass.123.top:3352
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# homeassistant
server {
listen 3352 ssl http2;
ssl_certificate /etc/nginx/cert/cert_nginx.pem;
ssl_certificate_key /etc/nginx/cert/cert_nginx.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name hass.123.top;
access_log /var/log/nginx/hass.123.top_nginx.log combined;
error_log /var/log/nginx/hass.123.top_nginx.error.log debug;
index index.html index.htm index.php;
if ($ssl_protocol = "") {
return 301 https://$host$request_uri;
}
#error_page 404 /404.html;
#error_page 502 /502.html;
charset utf-8; #默认编码方式
client_max_body_size 75M;
# 其他的请求全部交给Python的uWSGI来处理
location / {
proxy_pass http://192.168.3.345:8123;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
复制代码