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

Add log rotation #36

Open
gene1wood opened this issue Mar 9, 2022 · 0 comments
Open

Add log rotation #36

gene1wood opened this issue Mar 9, 2022 · 0 comments

Comments

@gene1wood
Copy link
Contributor

Enable log rotation of openresty web server logs.

Create a file /etc/logrotate.d/openresty with contents

# Make sure to first set the selinux context on the directory and files otherwise logrotate won't work
# semanage fcontext --add --type var_log_t '/usr/local/openresty/nginx/logs(/.*)?'
# restorecon -Frvv /usr/local/openresty/nginx/logs

/usr/local/openresty/nginx/logs/access.log /usr/local/openresty/nginx/logs/error.log {
        daily
        missingok
        rotate 30
        compress
        delaycompress
        notifempty
        create 644 root root
        sharedscripts
        postrotate
                if [ -f /usr/local/openresty/nginx/logs/nginx.pid ]; then
                        kill -USR1 `cat /usr/local/openresty/nginx/logs/nginx.pid`
                fi
        endscript
}

Set the selinux policy and file contexts by running

semanage fcontext --add --type var_log_t '/usr/local/openresty/nginx/logs(/.*)?'
restorecon -Frvv /usr/local/openresty/nginx/logs

I've done this manually on the live server but it's not captured here in the infrastructure-as-code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant