Skip to content

Commit 3748d66

Browse files
committed
fine-tune logging parameters
1 parent f9c5e1c commit 3748d66

17 files changed

+25
-16
lines changed

conf.d/common.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ server_names_hash_bucket_size 64;
2727
map $scheme $wpsc_https { default ''; https '-https'; }
2828

2929
# -------------------------------------------------------------------
30+
31+
### Fine-tune logging
32+
# ref: https://nginx.org/r/access_log
33+
map $status $loggable {
34+
~^[23] 0;
35+
default 1;
36+
}
37+
38+
# -------------------------------------------------------------------

sites-available/admin-over-ssl.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ server {
4646
ssl_certificate_key /path/to/server.key;
4747

4848
# Logs
49-
access_log /var/log/nginx/domainname.com-access.log;
49+
access_log /var/log/nginx/domainname.com-access.log combined buffer=64k flush=5m if=$loggable;
5050
error_log /var/log/nginx/domainname.com-error.log;
5151

5252
# Process requests to wp-admin/* and wp-login.php

sites-available/domainname.com.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ server {
1717
root /home/username/sites/domainname.com/wordpress;
1818

1919
# Logs - do check these, if sth goes wrong
20-
access_log /var/log/nginx/domainname.com-access.log;
20+
access_log /var/log/nginx/domainname.com-access.log combined buffer=64k flush=5m if=$loggable;
2121
error_log /var/log/nginx/domainname.com-error.log;
2222

2323
# Optional configurations

sites-available/ip.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ server {
55

66
root /home/username/others;
77

8-
access_log /var/log/nginx/ip-access.log;
8+
access_log /var/log/nginx/ip-access.log combined buffer=64k flush=5m if=$loggable;
99
error_log /var/log/nginx/ip-error.log;
1010

1111
location ~* \.php$ {

sites-available/login-over-ssl.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ server {
4242
ssl_certificate /path/to/combined.crt;
4343
ssl_certificate_key /path/to/server.key;
4444

45-
access_log /var/log/nginx/domainname.com-access.log;
45+
access_log /var/log/nginx/domainname.com-access.log combined buffer=64k flush=5m if=$loggable;
4646
error_log /var/log/nginx/domainname.com-error.log;
4747

4848
location ~ /wp-login\.php$ {

sites-available/mu-dir-dir-domainname.com.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ server {
2626
root /home/username/sites/domainname.com;
2727

2828
# Logs
29-
access_log /var/log/nginx/domainname.com-access.log;
29+
access_log /var/log/nginx/domainname.com-access.log combined buffer=64k flush=5m if=$loggable;
3030
error_log /var/log/nginx/domainname.com-error.log;
3131

3232
### modified version of globals/mu-files.conf;

sites-available/mu-dir-domainname.com.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ server {
1717
index index.php;
1818

1919
# logs
20-
access_log /var/log/nginx/domainname.com-access.log;
20+
access_log /var/log/nginx/domainname.com-access.log combined buffer=64k flush=5m if=$loggable;
2121
error_log /var/log/nginx/domainname.com-error.log;
2222

2323
include "globals/mu-files.conf";

sites-available/mu-dom-domainname.com.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ server {
1717
index index.php;
1818

1919
# logs
20-
access_log /var/log/nginx/domainname.com-access.log;
20+
access_log /var/log/nginx/domainname.com-access.log combined buffer=64k flush=5m if=$loggable;
2121
error_log /var/log/nginx/domainname.com-error.log;
2222

2323
include "globals/mu-files.conf";

sites-available/multiple-vhosts.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ server {
1717

1818
# Let's have a common log for all the sites
1919
# individual logs are not possible to create for each site
20-
access_log /var/log/nginx/common-vhost-access.log;
20+
access_log /var/log/nginx/common-vhost-access.log combined buffer=64k flush=5m if=$loggable;
2121
error_log /var/log/nginx/common-vhost-error.log error;
2222

2323
include "globals/restrictions.conf";

sites-available/nginx-varnish-apache.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ server {
1313
root /home/username/sites/domainname.com/wordpress;
1414

1515
error_log /var/log/nginx/domainname.com-error.log;
16-
access_log /var/log/nginx/domainname.com-access.log;
16+
access_log /var/log/nginx/domainname.com-access.log combined buffer=64k flush=5m if=$loggable;
1717

1818
location ~* \.(?:css|js|ico|svg)$ {
1919
add_header Cache-Control max-age=2678400;

0 commit comments

Comments
 (0)