---
apiVersion: v1
kind: ConfigMap
metadata:
  name: ingress-nginx-controller
  namespace: ingress-nginx
data:
  proxy-buffering: "off"
  # https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#proxy-body-size
  proxy-body-size: "256m"

  # be explicit about http2 (on by default)
  use-http2: "true"

  # increase tls session cache
  # https://docs.nginx.com/nginx/admin-guide/security-controls/terminating-ssl-tcp/
  ssl-session-cache-size: "20m"
  ssl-session-timeout: "4h"

  # compress static files
  use-gzip: "true"
  gzip-level: "5"
  enable-brotli: "true"
  brotli-level: "5"

  # http://nginx.org/en/docs/varindex.html
  log-format-upstream: >-
    {
    "time": "$time_iso8601",
    "request_id": "$req_id",
    "remote_user": "$remote_user",
    "bytes_sent": $bytes_sent,
    "body_bytes_sent": $body_bytes_sent,
    "request_time": $request_time,
    "status": $status,
    "host": "$host",
    "request_proto": "$server_protocol",
    "path": "$uri",
    "request_query": "$args",
    "request_length": $request_length,
    "method": "$request_method",
    "http_referrer": "$http_referer",
    "http_user_agent": "$http_user_agent",
    "upstream_addr": "$upstream_addr",
    "upstream_connect_time": $upstream_connect_time,
    "upstream_response_time": $upstream_response_time,
    "upstream_response_length": $upstream_response_length,
    "upstream_bytes_sent": $upstream_bytes_sent,
    "upstream_bytes_received": $upstream_bytes_received,
    "upstream_status": $upstream_status,
    "upstream_cache_status": "$upstream_cache_status"
    }
