Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3452 move nginx logs and static files to /var #3453

Merged
merged 2 commits into from
Nov 3, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ cat <<EOF >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}

Expand All @@ -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
Expand All @@ -109,7 +109,7 @@ echo "
maxage 3
}" >>/etc/logrotate.conf
echo "
/tmp/access.log {
/var/log/nginx/access.log {
missingok
notifempty
compress
Expand All @@ -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}"
Expand Down
6 changes: 3 additions & 3 deletions infrastructure/api-configuration/nginx_config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -50,7 +50,7 @@ http {

location /static {
autoindex on;
alias /tmp/volumes_static/;
alias /var/www/volumes_static/;
}

location / {
Expand Down
Loading