From d5b1f2325d72d25e7c8aa3617b4878ee52f731be Mon Sep 17 00:00:00 2001 From: Chris Hines <chris.hines@monash.edu> Date: Thu, 7 Jan 2021 11:13:16 +1100 Subject: [PATCH] Custom 502 error page when the tunnels don't open correctly --- .gitlab-ci.yml | 6 ++++++ html/502.html | 24 ++++++++++++++++++++++++ nginx_snippets/tes.conf | 6 ++++++ 3 files changed, 36 insertions(+) create mode 100644 html/502.html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad0e0f5..7f42775 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,6 +32,8 @@ deploy_test: script: - echo "deploying test" - cp ./nginx_snippets/* /etc/nginx/snippets/ + - mkdir -p /opt/strudel2/errors/ + - cp ./html/* /opt/strudel2/errors/ - docker login -u $DOCKERHUBUSER -p $DOCKERHUBPASSWORD docker.io - docker stop strudel2_backend || echo "Failed to stop existing container" - docker ps -a -q | xargs -I{} docker rm {} || echo "No containers to remove" @@ -52,6 +54,8 @@ deploy_dev: script: - echo "deploying dev" - cp ./nginx_snippets/* /etc/nginx/snippets/ + - mkdir -p /opt/strudel2/errors/ + - cp ./html/* /opt/strudel2/errors/ - docker login -u $DOCKERHUBUSER -p $DOCKERHUBPASSWORD docker.io - docker stop strudel2_backend || echo "Failed to stop existing container" - docker ps -a -q | xargs -I{} docker rm {} || echo "No containers to remove" @@ -72,6 +76,8 @@ deploy_prod: script: - echo "deploying prod" - cp ./nginx_snippets/* /etc/nginx/snippets/ + - mkdir -p /opt/strudel2/errors/ + - cp ./html/* /opt/strudel2/errors/ - docker login -u $DOCKERHUBUSER -p $DOCKERHUBPASSWORD docker.io - docker stop strudel2_backend || echo "Failed to stop existing container" - docker ps -a -q | xargs -I{} docker rm {} || echo "No containers to remove" diff --git a/html/502.html b/html/502.html new file mode 100644 index 0000000..1c6e707 --- /dev/null +++ b/html/502.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<pre id="log"></pre> +<html> + <head> </head> + <body> + Something isn't quite right<p> + Usually this indicates that the cluster hasn't quite managed to start your program and reloading this page should fix the issue<p> + This page should reload in a few seconds.<p> + If that still doesn't work, try closing this tab and clicking connect again + </body> +<script> +function sleep(ms, f) +{ + return( + setTimeout(f, ms) + ) +} + +sleep(5000, function() { + window.location.reload() + }) +</script> +</html> + diff --git a/nginx_snippets/tes.conf b/nginx_snippets/tes.conf index f108c73..f5b1d8b 100644 --- a/nginx_snippets/tes.conf +++ b/nginx_snippets/tes.conf @@ -1,3 +1,9 @@ +error_page 502 /502.html; +location /502.html { + root /opt/strudel2/errors/; +} + + location /tes/ { proxy_pass http://localhost:8080/; proxy_http_version 1.1; -- GitLab