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
4 changes: 2 additions & 2 deletions conf/nginx.conf.server.template
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ server {
## The time here is overridden by our injected `expires $cache_expiry` header.
proxy_cache_valid 200 206 1s;

access_log ${LOG_DIR}/cache.log proxy_cache;
${CACHE_ACCESS_LOG_DIRECTIVE}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be access_log ${LOG_DIR}/cache.log proxy_cache; when ENABLE_ACCESS_LOGS=true.

Will be access_log off; when ENABLE_ACCESS_LOGS is not set (default).

}
}

Expand Down Expand Up @@ -241,7 +241,7 @@ server {
proxy_ssl_trusted_certificate ./cacert.pem;
proxy_ssl_server_name on;

access_log ${LOG_DIR}/range_cache.log range_cache;
${RANGE_ACCESS_LOG_DIRECTIVE}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be access_log ${LOG_DIR}/range_cache.log range_cache; when ENABLE_ACCESS_LOGS=true.

Will be access_log off; when ENABLE_ACCESS_LOGS is not set (default).

}
}

Expand Down
4 changes: 2 additions & 2 deletions conf/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ http {
# Logging Settings
##

access_log ${LOG_DIR}/access.log;
error_log ${LOG_DIR}/error.log;
${ACCESS_LOG_DIRECTIVE}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be access_log ${LOG_DIR}/access.log; when ENABLE_ACCESS_LOGS=true.

Will be access_log off; when ENABLE_ACCESS_LOGS is not set (default).

error_log stderr ${ERROR_LOG_LEVEL};
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead log errors to stderr to be more compabitble with running in Docker.

ERROR_LOG_LEVEL is crit by default.


log_format proxy_cache '$remote_addr – $upstream_cache_status $status [$time_local] $request_method $proxy_method://$host$uri $body_bytes_sent "$http_referer" "$http_user_agent" ';

Expand Down
25 changes: 22 additions & 3 deletions scripts/generate_conf_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ then
export LOG_DIR="./logs"
fi

if [ "$ENABLE_ACCESS_LOGS" = "true" ]; then
export ACCESS_LOG_DIRECTIVE="access_log ${LOG_DIR}/access.log;"
export CACHE_ACCESS_LOG_DIRECTIVE="access_log ${LOG_DIR}/cache.log proxy_cache;"
export RANGE_ACCESS_LOG_DIRECTIVE="access_log ${LOG_DIR}/range_cache.log range_cache;"
else
export ACCESS_LOG_DIRECTIVE="access_log off;"
export CACHE_ACCESS_LOG_DIRECTIVE="access_log off;"
export RANGE_ACCESS_LOG_DIRECTIVE="access_log off;"
fi

# Levels can be warn, error crit, alert, and emerg.
if [ -z "$ERROR_LOG_LEVEL" ]
then
export ERROR_LOG_LEVEL="crit"
fi

if [ -z "$CONTENT_CACHE_DIR" ]
then
export CONTENT_CACHE_DIR="/data/funes/content_cache"
Expand Down Expand Up @@ -131,7 +147,10 @@ if [ -z "$PROXY_READ_DATA_TIMEOUT" ]
then
export PROXY_READ_DATA_TIMEOUT="60s"
fi

printf 'ERROR_LOG_LEVEL=%s\n' "$ERROR_LOG_LEVEL"
printf 'ACCESS_LOG_DIRECTIVE=%s\n' "$ACCESS_LOG_DIRECTIVE"
printf 'CACHE_ACCESS_LOG_DIRECTIVE=%s\n' "$CACHE_ACCESS_LOG_DIRECTIVE"
printf 'RANGE_ACCESS_LOG_DIRECTIVE=%s\n' "$RANGE_ACCESS_LOG_DIRECTIVE"
printf 'LOG_DIR=%s\n' "$LOG_DIR"
printf 'CONTENT_CACHE_DIR=%s\n' "$CONTENT_CACHE_DIR"
printf 'CONTENT_CACHE_KEYS_ZONE=%s\n' "$CONTENT_CACHE_KEYS_ZONE"
Expand All @@ -155,6 +174,6 @@ fi
echo "Nameserver is: $NAMESERVER"

echo "Copying nginx config"
envsubst '${ROOT_CA_CERT} ${ROOT_CA_KEY} ${LOG_DIR} ${PROXY_BUFFER_SIZE} ${PROXY_BUFFERS} ${PROXY_BUSY_BUFFERS_SIZE}' < ./conf/nginx.conf.template > ./conf/nginx.conf
envsubst '${PROXY_CONNECT_DATA_TIMEOUT} ${PROXY_READ_DATA_TIMEOUT} ${NAMESERVER} ${LOG_DIR} ${CONTENT_CACHE_DIR} ${CONTENT_CACHE_KEYS_ZONE} ${CONTENT_CACHE_SIZE} ${SSL_VERIFY_DEPTH}' < ./conf/nginx.conf.server.template > ./conf/nginx.conf.server
envsubst '${ROOT_CA_CERT} ${ROOT_CA_KEY} ${ERROR_LOG_LEVEL} ${ACCESS_LOG_DIRECTIVE} ${PROXY_BUFFER_SIZE} ${PROXY_BUFFERS} ${PROXY_BUSY_BUFFERS_SIZE}' < ./conf/nginx.conf.template > ./conf/nginx.conf
Comment thread
jschr marked this conversation as resolved.
envsubst '${PROXY_CONNECT_DATA_TIMEOUT} ${PROXY_READ_DATA_TIMEOUT} ${NAMESERVER} ${CACHE_ACCESS_LOG_DIRECTIVE} ${RANGE_ACCESS_LOG_DIRECTIVE} ${CONTENT_CACHE_DIR} ${CONTENT_CACHE_KEYS_ZONE} ${CONTENT_CACHE_SIZE} ${SSL_VERIFY_DEPTH}' < ./conf/nginx.conf.server.template > ./conf/nginx.conf.server
envsubst '${ROOT_CA_CERT} ${ROOT_CA_KEY} ${CERT_MEM_CACHE_TTL_SEC}' < ./conf/generate_ssl_certs.template.lua > ./conf/generate_ssl_certs.lua
Loading