Skip to content
Snippets Groups Projects
nginx.conf.j2 2.92 KiB
Newer Older
  • Learn to ignore specific revisions
  • load_module /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so;
    load_module /usr/lib/nginx/modules/ngx_http_brotli_static_module.so;
    
    include toplevel-snippets/*.conf;
    
        worker_connections 2048;
    
    
    worker_rlimit_nofile 2048;
    
    error_log syslog:server=unix:/dev/log,nohostname info;
    
    
        include mime.types;
        default_type application/octet-stream;
    
    
        log_format main
            '$remote_addr $host $remote_user [$time_local] "$request" '
            '$status $body_bytes_sent "$http_referer" '
            '"$http_user_agent" "$http_x_forwarded_for" $request_time';
    
        log_format reduced
            '$host [$time_local] "$request" '
            '$status $body_bytes_sent "$http_referer" '
            '"$http_user_agent"';
    
        log_format json_main escape=json
            '{'
            '"remote_addr":"$remote_addr",'
            '"host":"$host",'
            '"remote_user":"$remote_user",'
            '"time_local":"$time_local",'
    
            '"request_method":"$request_method",'
            '"request_uri":"$request_uri",'
    
            '"status": "$status",'
            '"body_bytes_sent":"$body_bytes_sent",'
            '"http_referrer":"$http_referer",'
            '"http_user_agent":"$http_user_agent",'
            '"http_x_forwarded_for":"$http_x_forwarded_for",'
    
            '"request_time":"$request_time",'
            # This was added to keep every log line unique as Loki drops
            # log line with the same timestamp and log text:
            # https://grafana.com/docs/loki/latest/overview/#timestamp-ordering
            '"connection":"$connection",'
            '"connection_requests":"$connection_requests"'
    
            '}';
    
        log_format json_reduced escape=json
            '{'
            '"host":"$host",'
            '"time_local":"$time_local",'
    
            '"request_method":"$request_method",'
            '"request_uri":"$request_uri",'
    
            '"status": "$status",'
            '"body_bytes_sent":"$body_bytes_sent",'
            '"http_referrer":"$http_referer",'
            '"http_user_agent":"$http_user_agent",'
    
            # This was added to keep every log line unique as Loki drops
            # log line with the same timestamp and log text:
            # https://grafana.com/docs/loki/latest/overview/#timestamp-ordering
            '"connection":"$connection",'
            '"connection_requests":"$connection_requests"'
    
            '}';
    
        sendfile on;
        keepalive_timeout 65;
    
        gzip on;
        gzip_comp_level 6;
    
        gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    
        brotli_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    
        server_tokens off;
    
    
        index index.php index.html index.htm;
    
        access_log syslog:server=unix:/dev/log,nohostname,tag=nginx_http main;
    
        include snippets/sslsettings.conf;