It appears your nginx config is not properly setup for websockets which home assistant relies on to connect/stay open.
See my sample config here, the important thing to add I believe are these lines to “upgrade” the connection and keep websockets open.
location /api/websocket {
resolver 127.0.0.11 valid=30s;
set $upstream_app homeassistant;
set $upstream_port 8123;
set $upstream_proto http;
proxy_pass http://192.168.0.184:8123;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Websocket config is explained more in this article
https://www.google.com/amp/s/www.nginx.com/blog/websocket-nginx/amp/