Skip to content

Instantly share code, notes, and snippets.

@OmeGak
Last active August 9, 2016 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save OmeGak/f9b21627128220fc0531859ea16ca019 to your computer and use it in GitHub Desktop.
Save OmeGak/f9b21627128220fc0531859ea16ca019 to your computer and use it in GitHub Desktop.
NGINX 502 autoreload
<head>
<title>502 Bad Gateway</title>
</head>
<body>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
<script>
function tryRefresh() {
var xhr = new XMLHttpRequest();
xhr.open('GET', location.href);
xhr.send(null);
xhr.onreadystatechange = function() {
var DONE = 4;
if (xhr.readyState === DONE) {
if (xhr.status != 502) {
location.reload(true);
} else {
setTimeout(tryRefresh, 1000);
}
}
};
}
tryRefresh();
</script>
</body>
http {
# ...
server {
# ...
error_page 502 /502.html;
location = /502.html {
alias /home/omegak/.dotfiles/indico/502.html;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment