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..3e8cfc3 100644 --- a/src/10-setup.sh +++ b/src/10-setup.sh @@ -14,10 +14,14 @@ 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 -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 +29,16 @@ gzip_types ${GZIP_TYPES}; EOF 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 -cat < /etc/nginx/conf.d/location.auth.conf +cat <> /etc/nginx/conf.d/location.auth.conf auth_basic "${BASIC_REALM:-Unauthorized}"; auth_basic_user_file /etc/nginx/auth.users; EOF diff --git a/src/nginx.conf b/src/nginx.conf index aec5d74..31e2c4a 100644 --- a/src/nginx.conf +++ b/src/nginx.conf @@ -26,6 +26,7 @@ http { root /static; index NGINX_INDEX; autoindex on; + try_files $uri $uri.html $uri/ =404; include /etc/nginx/conf.d/location.*; } }