This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
nginx.conf.template
92 lines (73 loc) · 2.86 KB
/
nginx.conf.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main escape=json
'{ "@timestamp": "$time_iso8601", '
'"message": "$request", '
'"client_addr": "$http_x_forwarded_for", '
'"status": $status, '
'"body_bytes_sent": $body_bytes_sent, '
'"request_time": $request_time, '
'"referrer": "$http_referer", '
'"user_agent": "$http_user_agent", '
'"protocol": "$server_protocol", '
'"method": "$request_method", '
'"scheme": "$http_x_forwarded_proto", '
'"host": "$http_host", '
'"uri": "$uri", '
'"params": "$args", '
'"url": "$http_x_forwarded_proto://$http_host$request_uri", '
'"business_unit": "$http_x_business_unit", '
'"language": "$http_x_language", '
'"client": "$http_x_client", '
'"timezone": "$http_x_timezone", '
'"sec_fetch_dest": "$http_sec_fetch_dest", '
'"sec_fetch_mode": "$http_sec_fetch_mode", '
'"sec_fetch_site": "$http_sec_fetch_site", '
'"cache": "$upstream_cache_status" }';
# default: ignore certain paths on 2XX and 3XX status codes
map $status$uri $log_filter_default {
~^[0-9]*/nice2/rest/(entity|entities)/[A-Z] 1;
~^[23][0-9]*/(cms/|css/|fonts/|img/|js/|nice2/(javascript/|textresource$)|status-tocco(-nginx)?$) 0;
default 1;
}
# verbose: log everything but status pages (those are used by probes and monitoring mostly)
map $status$uri $log_filter_verbose {
~^[23][0-9]*/status-tocco(-nginx)?$ 0;
default 1;
}
# all: log every single request
map $status$uri $log_filter_all {
default 1;
}
access_log /var/log/nginx/access.log main if=$log_filter_{{ NGINX_LOG_LEVEL|default('default') }};
charset utf-8;
server_tokens off;
sendfile on;
client_body_buffer_size 64K;
client_max_body_size 400M;
keepalive_timeout 65;
gzip on;
gzip_proxied any;
gzip_vary on;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
proxy_cache_key $http_x_forwarded_proto:$host$request_uri;
proxy_cache_path /var/cache/nginx/proxy_cache levels=2 keys_zone=cache:10m inactive=1d max_size=2g;
proxy_temp_path /var/cache/nginx/proxy_temp/ 2;
real_ip_header X-Forwarded-For;
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 127.0.0.1;
set_real_ip_from ::1;
# WebSocket support
map $http_upgrade $connection_upgrade {
default upgrade;
'' '';
}
include /etc/nginx/conf.d/*.conf;
}