Binding the app to localhost and putting nginx in front is the right shape for a single-host Compose stack — just make sure the proxy and the container share a path that actually reaches that listen address (same host network namespace, or a published internal port on a user-defined bridge with proxy_pass by service name). n8n’s editor and webhook traffic need WebSocket Upgrade headers and a Connection upgrade on that location; do not reuse the “clear Connection for keepalive” pattern from a plain REST upstream on the same block or the UI drops mid-session.
Raise proxy_read_timeout and proxy_send_timeout above the longest workflow or webhook you expect, and terminate TLS at nginx with the usual Host / X-Forwarded-For / X-Forwarded-Proto headers so the app builds public URLs correctly. After compose up or a cert reload I hit a cheap health path from the nginx side to the upstream name first, then through the public vhost, and watch error_log for connect() failed versus upstream timed out — that tells you whether to fix reachability or just the timeout budget.