Is this a standard install or do you have a reverse proxy in front of Discourse?
Given that your have some other reverse proxy, it sounds like some kind of race condition where it needs to be running first, or perhaps the external nginx is creating a network that Discourse cannot connect to if discourse starts first