From 57c39b1466cf8e421db5265ffdf8c73001f100d5 Mon Sep 17 00:00:00 2001 From: ChisSoc <75833833+ChisSoc@users.noreply.github.com> Date: Sun, 5 Dec 2021 23:02:06 +0100 Subject: [PATCH] Give helpfull 404 pages with hints how to resolve the underlying issues --- resources/default-settings/nginx.default | 47 ++++++++++++++++++++++-- resources/html/404.html | 22 +++++++++++ resources/html/runbuildui.html | 24 ++++++++++++ resources/html/runsphinx.html | 24 ++++++++++++ 4 files changed, 113 insertions(+), 4 deletions(-) create mode 100755 resources/html/404.html create mode 100755 resources/html/runbuildui.html create mode 100755 resources/html/runsphinx.html diff --git a/resources/default-settings/nginx.default b/resources/default-settings/nginx.default index 139603c18..23d5525e5 100644 --- a/resources/default-settings/nginx.default +++ b/resources/default-settings/nginx.default @@ -9,12 +9,51 @@ server { server_name _; location / { + location = /index.html { + error_page 404 = @buildwebui; + log_not_found off; + } + location = / { + error_page 404 = @buildwebui; + log_not_found off; + } try_files $uri $uri/ =404; } - location /docs { - alias /home/pi/RPi-Jukebox-RFID/docs/sphinx/_build/html/; - index index.html index.htm; - } + location /docs { + root /home/pi/RPi-Jukebox-RFID/docs/sphinx/_build/html; + try_files $uri $uri/ =404; + location = /docs/index.html { + error_page 404 = @runsphinx; + log_not_found off; + } + location = /docs { + error_page 404 = @runsphinx; + log_not_found off; + } + location = /docs/ { + error_page 404 = @runsphinx; + log_not_found off; + } + + } + + location @runsphinx { + root /home/pi/RPi-Jukebox-RFID/resources/html; + try_files /runsphinx.html =404; + internal; + } + + location @buildwebui { + root /home/pi/RPi-Jukebox-RFID/resources/html; + try_files /runbuildui.html =404; + internal; + } + + error_page 404 = /404.html; + location /404.html { + root /home/pi/RPi-Jukebox-RFID/resources/html; + internal; + } } diff --git a/resources/html/404.html b/resources/html/404.html new file mode 100755 index 000000000..6b522326a --- /dev/null +++ b/resources/html/404.html @@ -0,0 +1,22 @@ + +
+ +++ + diff --git a/resources/html/runbuildui.html b/resources/html/runbuildui.html new file mode 100755 index 000000000..01a24052b --- /dev/null +++ b/resources/html/runbuildui.html @@ -0,0 +1,24 @@ + + + +Ups! Requested file not found.
+Why not try again from the top-level of +
+
++ + diff --git a/resources/html/runsphinx.html b/resources/html/runsphinx.html new file mode 100755 index 000000000..a59cc2e3a --- /dev/null +++ b/resources/html/runsphinx.html @@ -0,0 +1,24 @@ + + + +Ups! Looks like your Web UI has not been build!
+No reason to panic. Please run through the following steps: +
+
+- cd /home/pi/RPi-Jukebox-RFID/src/webapp
+- ./run_rebuild.sh
+- Reload this page
+In case of trouble when building the Web UI, consult the documentation! +
++ +Ups! Looks like your documentation has not been build!
+No reason to panic. Please run through the following steps: +
+
+- cd /home/pi/RPi-Jukebox-RFID
+- ./run_sphinx.sh -c
+- Reload this page
+Or check out the online documentation at Read The Docs. +