From 6f928b6afe514c2c670e83f93361cc17f152c7c3 Mon Sep 17 00:00:00 2001 From: David Mejia Date: Fri, 3 Nov 2023 11:26:10 -0400 Subject: [PATCH 1/2] update nginx log location --- .../api-server-instance-user-data.tpl.sh | 12 ++++++------ infrastructure/api-configuration/nginx_config.conf | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/infrastructure/api-configuration/api-server-instance-user-data.tpl.sh b/infrastructure/api-configuration/api-server-instance-user-data.tpl.sh index 3bc0edc7e..e107e8aa2 100644 --- a/infrastructure/api-configuration/api-server-instance-user-data.tpl.sh +++ b/infrastructure/api-configuration/api-server-instance-user-data.tpl.sh @@ -83,13 +83,13 @@ cat <awslogs.conf [general] state_file = /var/lib/awslogs/agent-state -[/tmp/error.log] -file = /tmp/error.log +[/var/log/nginx/error.log] +file = /var/log/nginx/error.log log_group_name = ${log_group} log_stream_name = log-stream-api-nginx-error-${user}-${stage} -[/tmp/access.log] -file = /tmp/access.log +[/var/log/nginx/access.log] +file = /var/log/nginx/access.log log_group_name = ${log_group} log_stream_name = log-stream-api-nginx-access-${user}-${stage} @@ -100,7 +100,7 @@ wget https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setu python3.5 ./awslogs-agent-setup.py --region "${region}" --non-interactive --configfile awslogs.conf # Rotate the logs, delete after 3 days. echo " -/tmp/error.log { +/var/log/nginx/error.log { missingok notifempty compress @@ -109,7 +109,7 @@ echo " maxage 3 }" >>/etc/logrotate.conf echo " -/tmp/access.log { +/var/log/nginx/access.log { missingok notifempty compress diff --git a/infrastructure/api-configuration/nginx_config.conf b/infrastructure/api-configuration/nginx_config.conf index 221e774d9..3b025c18f 100644 --- a/infrastructure/api-configuration/nginx_config.conf +++ b/infrastructure/api-configuration/nginx_config.conf @@ -3,7 +3,7 @@ # Optionally, we can have Nginx sort itself out: worker_processes auto; -error_log /tmp/error.log error; +error_log /var/log/nginx/error.log error; events { # Set this to ulimit -n @@ -25,7 +25,7 @@ http { '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /tmp/access.log main; + access_log /var/log/nginx/access.log main; sendfile on; client_body_timeout 12; From 488d32bf992ab0b23092fdbcfd6d2e49e863be3d Mon Sep 17 00:00:00 2001 From: David Mejia Date: Fri, 3 Nov 2023 11:28:21 -0400 Subject: [PATCH 2/2] serve static files from var/www/static_volumes --- .../api-configuration/api-server-instance-user-data.tpl.sh | 6 +++--- infrastructure/api-configuration/nginx_config.conf | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infrastructure/api-configuration/api-server-instance-user-data.tpl.sh b/infrastructure/api-configuration/api-server-instance-user-data.tpl.sh index e107e8aa2..8197ffde1 100644 --- a/infrastructure/api-configuration/api-server-instance-user-data.tpl.sh +++ b/infrastructure/api-configuration/api-server-instance-user-data.tpl.sh @@ -125,9 +125,9 @@ EOF chown -R ubuntu /home/ubuntu -STATIC_VOLUMES=/tmp/volumes_static -mkdir -p /tmp/volumes_static -chmod a+rwx /tmp/volumes_static +STATIC_VOLUMES=/var/www/volumes_static +mkdir -p /var/www/volumes_static +chmod a+rwx /var/www/volumes_static # Pull the API image. docker pull "${dockerhub_repo}/${api_docker_image}" diff --git a/infrastructure/api-configuration/nginx_config.conf b/infrastructure/api-configuration/nginx_config.conf index 3b025c18f..4b9052212 100644 --- a/infrastructure/api-configuration/nginx_config.conf +++ b/infrastructure/api-configuration/nginx_config.conf @@ -50,7 +50,7 @@ http { location /static { autoindex on; - alias /tmp/volumes_static/; + alias /var/www/volumes_static/; } location / {