Activate Log Rotate Nginx
nano /etc/logrotate.d/nginx
/var/log/nginx/*.log {
daily
missingok
rotate 7
size 5k
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
invoke-rc.d nginx rotate >/dev/null 2>&1
endscript
}
sudo logrotate -v -f /etc/logrotate.d/nginx
nano /etc/nginx/nginx.conf
access_log /var/log/nginx/access.log custom;
error_log /var/log/nginx/error.log;
Forward Client IP / Source IP
nano /etc/nginx/conf.d/*.conf
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
nano /etc/nginx/nginx.conf
http {
set_real_ip_from 10.8.0.1/32;
real_ip_header X-Forwarded-For;
}
nano /etc/nginx/nginx.conf
http {
log_format custom '$remote_addr - $remote_user [$time_local] "$request" "$request_body"'
' "$http_UID" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
}
server {
listen 80;
location / {
root /your/file/directory/;
autoindex on;
allow all;
}
}