summaryrefslogtreecommitdiff
path: root/nginx.conf
blob: d58f4b1ddf30a4a489d45e328a5f2435937b8031 (plain)
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
user www-data;
worker_processes 1;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
    worker_connections 512;
}
http {
	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;

    # `$upstream_http_x_route` and $upstream_http_x_cache_hit are custom headers set by me in the flask app
    #  All values needs to be in quotes b/c if a variable is empty, it puts '-' which is not valid json
    log_format json_logs escape=json '{'
        '"time_local":"$time_local",'
        '"time":"$msec",'
        '"client":"$remote_addr",'
        '"forwarded_for":"$http_x_forwarded_for",'
        '"method":"$request_method",'
        '"request":"$request",'
        '"request_length":"$request_length",'
        '"status":"$status",'
        '"bytes_sent":"$bytes_sent",'
        '"referer":"$http_referer",'
        '"user_agent":"$http_user_agent",'
        '"upstream_status":"$upstream_status",'
        '"request_time":"$request_time",'
        '"upstream_response_time":"$upstream_response_time",'
        '"upstream_connect_time":"$upstream_connect_time",'
        '"upstream_header_time":"$upstream_header_time",'
        '"upstream_route":"$upstream_http_x_route",'
        '"upstream_cache_hit":"$upstream_http_x_cache_hit",'
        '"host":"$host",'
        '"http_host":"$http_host"'
    '}';

    access_log /var/log/nginx/access.log json_logs;
    error_log /var/log/nginx/error.log;
}