From a947004e543aacf3a46579cbc94c44bef46cd8f0 Mon Sep 17 00:00:00 2001 From: pierre Date: Wed, 23 Apr 2025 10:13:42 +0100 Subject: [PATCH] add nginx.conf logging option --- nginx-config.configmap.yaml | 43 +++++++++++++++++++++++++++++++++++++ nginx.conf | 28 ++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 nginx-config.configmap.yaml diff --git a/nginx-config.configmap.yaml b/nginx-config.configmap.yaml new file mode 100644 index 0000000..354f6f0 --- /dev/null +++ b/nginx-config.configmap.yaml @@ -0,0 +1,43 @@ +apiVersion: v1 +data: + nginx.conf: "worker_processes 1;\nevents { worker_connections 1024; }\n\nhttp {\n\n\tsendfile + on;\n\tclient_max_body_size 1500M; \n\tserver_names_hash_bucket_size 1024;\n proxy_http_version + \ 1.1;\n proxy_set_header X-Forwarded-Scheme $scheme;\n + \ proxy_set_header Accept-Encoding \"\";\n\tproxy_set_header + \ Host $host;\n\tproxy_set_header X-Real-IP $remote_addr;\n\tproxy_set_header + \ X-Forwarded-For $proxy_add_x_forwarded_for;\n\tproxy_set_header X-Forwarded-Host + $server_name;\n\t#proxy_set_header Upgrade $http_upgrade;\n\t#proxy_set_header + Connection 'upgrade';\n\t#proxy_cache_bypass $http_upgrade; \n\n\tgzip on;\n\tgzip_types + text/plain application/xml application/json image/svg+xml text/css;\n\tgzip_min_length + 1000;\n \n\tlog_format my_custom_format '$http_host $remote_addr - $remote_user + [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\"';\n\n\n\tserver + {\n\tlisten 80;\n listen 443 default ssl;\n\tssl_certificate /etc/nginx/ssl/live/default.tryton.geeraert.eu/fullchain.pem; + # managed by$\n ssl_certificate_key /etc/nginx/ssl/live/default.tryton.geeraert.eu/privkey.pem; + # managed $\n location / {\n proxy_pass http://1.1.1.1;\n + \ proxy_redirect off;\n proxy_set_header Host $host;\n + \ proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header + \ X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Host + $server_name;\n\t\t}\n\t}\n\t# Connection header for WebSocket reverse proxy\n\tmap + $http_upgrade $connection_upgrade {\n\t\tdefault upgrade;\n '' close;\n\t}\n\n\tinclude + /etc/nginx/conf.d/*.conf;\n\tresolver 127.0.0.1 ipv6=off valid=40s; # The DNS + IP server\n\t\n\t#https://www.tweaked.io/guide/nginx-proxying/\n\tproxy_cache_path + /tmp/cache levels=1:2 keys_zone=cache:60m max_size=1G;\n\n#\tlog_format main '$remote_addr + - $remote_user [$time_local] '\n# '\"$request\" $status + $body_bytes_sent '\n# '\"$http_referer\" \"$http_user_agent\" + \"$gzip_ratio\"'\n# 'host - $host '\n# '$scheme + $proxy_add_x_forwarded_for '\n# '$remote_addr [$time_local]'\n# + \ '\"$request\" $status $body_bytes_sent '\n# '\"$http_referer\" + \"$http_user_agent\"'\n# '\"$request\" $status $body_bytes_sent + '\n# '\"$http_referer\" \"$http_user_agent\" \"$gzip_ratio\"';\n\n# + \ log_format upstream_time '$remote_addr - $remote_user [$time_local] '\n# '\"$request\" + $status $body_bytes_sent '\n# '\"$http_referer\" \"$http_user_agent\"'\n# + \ 'host + $host '\n# '$scheme + $proxy_add_x_forwarded_for '\n# '$remote_addr [$time_local]'\n# + \ '\"$request\" $status $body_bytes_sent '\n# '\"$http_referer\" + \"$http_user_agent\"'\n# 'rt=$request_time uct=\"$upstream_connect_time\" + uht=\"$upstream_header_time\" urt=\"$upstream_response_time\"';\n\n\n}\n\n\n" +kind: ConfigMap +metadata: + creationTimestamp: null + name: nginx-config + namespace: reverse-proxy diff --git a/nginx.conf b/nginx.conf index f38cad8..b40b9be 100755 --- a/nginx.conf +++ b/nginx.conf @@ -4,7 +4,7 @@ events { worker_connections 1024; } http { sendfile on; - client_max_body_size 500M; + client_max_body_size 1500M; server_names_hash_bucket_size 1024; proxy_http_version 1.1; proxy_set_header X-Forwarded-Scheme $scheme; @@ -20,6 +20,8 @@ http { gzip on; gzip_types text/plain application/xml application/json image/svg+xml text/css; gzip_min_length 1000; + + log_format my_custom_format '$http_host $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'; server { @@ -40,7 +42,7 @@ http { map $http_upgrade $connection_upgrade { default upgrade; '' close; - } + } include /etc/nginx/conf.d/*.conf; resolver 127.0.0.1 ipv6=off valid=40s; # The DNS IP server @@ -48,6 +50,28 @@ http { #https://www.tweaked.io/guide/nginx-proxying/ proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:60m max_size=1G; +# log_format main '$remote_addr - $remote_user [$time_local] ' +# '"$request" $status $body_bytes_sent ' +# '"$http_referer" "$http_user_agent" "$gzip_ratio"' +# 'host - $host ' +# '$scheme $proxy_add_x_forwarded_for ' +# '$remote_addr [$time_local]' +# '"$request" $status $body_bytes_sent ' +# '"$http_referer" "$http_user_agent"' +# '"$request" $status $body_bytes_sent ' +# '"$http_referer" "$http_user_agent" "$gzip_ratio"'; + +# log_format upstream_time '$remote_addr - $remote_user [$time_local] ' +# '"$request" $status $body_bytes_sent ' +# '"$http_referer" "$http_user_agent"' +# 'host + $host ' +# '$scheme $proxy_add_x_forwarded_for ' +# '$remote_addr [$time_local]' +# '"$request" $status $body_bytes_sent ' +# '"$http_referer" "$http_user_agent"' +# 'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"'; + + }