Note to Self: Fixing n8n "Connection Lost" with Nginx Reverse Proxy

If you are having issues with n8n reporting “Connection Lost” when being run through an Nginx proxy, you need to check two things:

1. Check That These Environment Variables Are Defined for n8n

WEBHOOK_URL=https://n8n.example.com # so our webhooks are formatted correctly
WEBHOOK_TUNNEL_URL=https://n8n.example.com # IDK, but breaks if you don't
VUE_APP_URL_BASE_API=https://n8n.example.com # so n8n can find itself

2. Check Your Nginx Configuration

This is important if you are seeing this issue on Firefox. For Firefox, Nginx’s default settings result in errors when using Server-Sent Events (SSE). Make sure your location has the following configuration:

# required for Server Sent Events
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;

From what I have been able to piece together from snippets of forum posts, issues, and n8n’s documentation.