I’ve got a droplet currently running my website (a Ghost blog) behind an NGINX reverse proxy that handles all the HTTPS redirects, etc. etc.
It’s all working really well (thanks to the tutorials and answer writers on here), but my one gripe is that when I run updates and reboot the box, NGINX kicks in before Ghost loads up, meaning that anyone who happens to load my site in that 5-10 second interval gets a nice big 502 Bad Gateway error.
Is there any way to make this work a little more gracefully, so that users that open the site at that point just get put on hold for a few seconds rather than immediately getting booted to the error page and having to refresh?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I have created a spinner for a customer (loading animation) and then the site refreshes every 5 seconds. But I don’t have access to their platform right now, so I’ll give you a link to a pretty good example in the first answer: http://stackoverflow.com/questions/10895071/how-to-create-custom-error-502-nginx-in-core-of-nginx-not-using-redirect-to-err
The issue here is the delay with Ghost. There’s really no way to preload Ghost so that it comes up at the same time as NGINX as Ghost relies on npm to do its thing before starting up.
If you start Ghost first, there’s no web server to handle the requests during the delay and the only way to access Ghost would be using a port, if you’ve set it to work on a public IP – you’d still be getting an error since requests on port 80 will fail.
If you start NGINX first, then you’re waiting on Ghost, thus since NGINX can’t access Ghost right now, you get the 502 since NGINX can’t proxy.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.