add option to turn on access log

This commit is contained in:
Asif Bacchus
2019-10-18 01:53:20 -06:00
parent d6e49f4d09
commit bfdb85b384
4 changed files with 19 additions and 3 deletions
+1
View File
@@ -35,6 +35,7 @@ ENV TZ=Etc/UTC
ENV SERVER_NAMES="_"
ENV HTTP_PORT=80
ENV HTTPS_PORT=443
ENV ACCESS_LOG=OFF
ENV HSTS=FALSE
ENV TLS13_ONLY=FALSE
+1 -2
View File
@@ -35,8 +35,7 @@ http {
'uaddr="$upstream_addr" ustat="$upstream_status" '
'utime="$upstream_response_time" ulen="$upstream_response_length" '
'cache="$upstream_cache_status"';
#access_log /var/log/nginx/access.log main;
access_log off;
access_log <ACCESS_LOG_SETTING>;
# server configuration options
server_tokens off;
+11
View File
@@ -10,6 +10,17 @@ printf "\nUpdating server name list... "
sed -i -e "s%<SERVER_NAMES>%${SERVER_NAMES}%" /etc/nginx/server_names.conf
printf "done\n"
# update access log global preference
if [ "$ACCESS_LOG" = "OFF" ]; then
printf "Turning access log OFF..."
sed -i -e "s%<ACCESS_LOG_SETTING>%OFF%" /etc/nginx/nginx.conf
printf "done\n"
elif [ "$ACCESS_LOG" = "ON" ]; then
printf "Turning access log ON..."
sed -i -e "s%<ACCESS_LOG_SETTING>%/var/log/nginx/access.log combined%" /etc/nginx/nginx.conf
printf "done\n"
fi
# update HTTPS redirect port if SSL server test block exists
if [ -f "/etc/nginx/sites/note" ]; then
printf "\nUpdating port redirects...\n"