From 4447af6817f6fcee0b9ef4476d018d737321c95a Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Tue, 21 Oct 2025 20:02:37 -0700 Subject: [PATCH 1/4] Add try_files --- src/nginx.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nginx.conf b/src/nginx.conf index aec5d74..52d1326 100644 --- a/src/nginx.conf +++ b/src/nginx.conf @@ -26,6 +26,7 @@ http { root /static; index NGINX_INDEX; autoindex on; + try_files $uri.html $uri.htm $uri /index.html; include /etc/nginx/conf.d/location.*; } } From 4f09ee3898a4cca55ef207044fb673f5b2994198 Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Tue, 21 Oct 2025 20:08:53 -0700 Subject: [PATCH 2/4] Add try_files --- src/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nginx.conf b/src/nginx.conf index 52d1326..31e2c4a 100644 --- a/src/nginx.conf +++ b/src/nginx.conf @@ -26,7 +26,7 @@ http { root /static; index NGINX_INDEX; autoindex on; - try_files $uri.html $uri.htm $uri /index.html; + try_files $uri $uri.html $uri/ =404; include /etc/nginx/conf.d/location.*; } } From a55bc0323de5caae0351b882a37536214ce5cf1d Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Tue, 21 Oct 2025 20:18:47 -0700 Subject: [PATCH 3/4] Add ERROR_PAGE --- README.md | 1 + src/10-setup.sh | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2948251..ad23fab 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Coming Soon... | STATIC | /static | Nginx root directory | | SUID | 1000 | Directory group/user ID | | NGINX_INDEX | `index.html index.htm` | Nginx directory index files | +| ERROR_PAGE | `/404.html` | Nginx 404 page, set `off` to disable | | GZIP_TYPES | `*` | Nginx gzip_types, set `off` to disable | | GZIP_LENGTH | `1000` | Minimum content size to compress | | BASIC_AUTH | - | Basic auth file contents | diff --git a/src/10-setup.sh b/src/10-setup.sh index 628ddf8..39b7953 100644 --- a/src/10-setup.sh +++ b/src/10-setup.sh @@ -17,7 +17,7 @@ sed "s/NGINX_INDEX/${NGINX_INDEX:=$_NGINX_INDEX}/g" \ : "${GZIP_TYPES:=*}" echo "GZIP_TYPES: ${GZIP_TYPES}" if [ "${GZIP_TYPES}" != "off" ];then -cat < /etc/nginx/conf.d/http.gzip.conf +cat <> /etc/nginx/conf.d/http.gzip.conf gzip on; gzip_proxied any; gzip_min_length ${GZIP_LENGTH:-1000}; @@ -25,10 +25,15 @@ gzip_types ${GZIP_TYPES}; EOF fi +: "${ERROR_PAGE:=/404.html}" +if [ "${ERROR_PAGE}" != "off" ];then + echo "error_page 404 ${ERROR_PAGE};" >> /etc/nginx/conf.d/location.auth.conf +fi + if [ -n "${BASIC_AUTH}" ];then echo "BASIC_AUTH: ${BASIC_AUTH}" -printf '%s' "${BASIC_AUTH}" > /etc/nginx/auth.users -cat < /etc/nginx/conf.d/location.auth.conf +printf '%s' "${BASIC_AUTH}" >> /etc/nginx/auth.users +cat <> /etc/nginx/conf.d/location.auth.conf auth_basic "${BASIC_REALM:-Unauthorized}"; auth_basic_user_file /etc/nginx/auth.users; EOF From 9cb02e7c59f2e9ad5220466b5df52d938b1d61a8 Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Tue, 21 Oct 2025 20:25:54 -0700 Subject: [PATCH 4/4] Cleanup, Literally --- src/10-setup.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/10-setup.sh b/src/10-setup.sh index 39b7953..3e8cfc3 100644 --- a/src/10-setup.sh +++ b/src/10-setup.sh @@ -14,6 +14,10 @@ echo "NGINX_INDEX: ${NGINX_INDEX:=$_NGINX_INDEX}" sed "s/NGINX_INDEX/${NGINX_INDEX:=$_NGINX_INDEX}/g" \ -i /etc/nginx/nginx.conf +rm -f /etc/nginx/conf.d/http.gzip.conf +rm -f /etc/nginx/conf.d/location.auth.conf +rm -f /etc/nginx/auth.users + : "${GZIP_TYPES:=*}" echo "GZIP_TYPES: ${GZIP_TYPES}" if [ "${GZIP_TYPES}" != "off" ];then @@ -27,12 +31,13 @@ fi : "${ERROR_PAGE:=/404.html}" if [ "${ERROR_PAGE}" != "off" ];then + echo "ERROR_PAGE: ${ERROR_PAGE}" echo "error_page 404 ${ERROR_PAGE};" >> /etc/nginx/conf.d/location.auth.conf fi if [ -n "${BASIC_AUTH}" ];then echo "BASIC_AUTH: ${BASIC_AUTH}" -printf '%s' "${BASIC_AUTH}" >> /etc/nginx/auth.users +printf '%s' "${BASIC_AUTH}" > /etc/nginx/auth.users cat <> /etc/nginx/conf.d/location.auth.conf auth_basic "${BASIC_REALM:-Unauthorized}"; auth_basic_user_file /etc/nginx/auth.users;