Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
14 changes: 12 additions & 2 deletions src/10-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,31 @@ 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 <<EOF > /etc/nginx/conf.d/http.gzip.conf
cat <<EOF >> /etc/nginx/conf.d/http.gzip.conf
gzip on;
gzip_proxied any;
gzip_min_length ${GZIP_LENGTH:-1000};
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 <<EOF > /etc/nginx/conf.d/location.auth.conf
cat <<EOF >> /etc/nginx/conf.d/location.auth.conf
auth_basic "${BASIC_REALM:-Unauthorized}";
auth_basic_user_file /etc/nginx/auth.users;
EOF
Expand Down
1 change: 1 addition & 0 deletions src/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
}
}
Expand Down