diff --git a/README.md b/README.md index 0743f69..0fb7e48 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,4 @@ Variable | Example | Description --- | --- | --- `SERVER_MAX_BODY_SIZE` | `SERVER_MAX_BODY_SIZE=4M` | Allows the downstream application to specify a non-default `client_max_body_size` configuration for the `server`-level directive in `/etc/nginx/sites-available/default` `SERVER_INDEX` | `SERVER_INDEX index.html index.html index.php` | Changes the default pages to hit for folder and web roots +`SERVER_APP_NAME` | `APP_NAME='view'` | Sets a kv pair to be consumed by logging service for easy parsing and searching diff --git a/container/root/run.sh b/container/root/run.sh index c752a53..ee84332 100755 --- a/container/root/run.sh +++ b/container/root/run.sh @@ -9,8 +9,9 @@ sed -i "s/worker_processes [0-9]\+/worker_processes $(nproc)/" $CONFIG_SERVER sed -i "s/worker_connections [0-9]\+/worker_connections 1024/" $CONFIG_SERVER echo '[nginx] piping logs to STDOUT' - -sed -i "s/access_log [a-z\/\.\;]\+/access_log \/dev\/stdout;/" $CONFIG_SERVER +# Ensure nginx is configured to write logs to STDOUT +# Also set log_format to output SERVER_APP_NAME placeholder +sed -i "s/access_log [a-z\/\.\;]\+/ log_format main \'\$remote_addr - \$remote_user [\$time_local] \"\$request\" \$status \$bytes_sent \"\$http_referer\" \"\$http_user_agent\" SERVER_APP_NAME\';\n access_log \/dev\/stdout main;\n/" $CONFIG_SERVER sed -i "s/error_log [a-z\/\.\ \;]\+/error_log \/dev\/stdout info;/" $CONFIG_SERVER if [[ $SERVER_MAX_BODY_SIZE ]]