Skip to content

Instantly share code, notes, and snippets.

@arbakker
Created May 8, 2024 06:42
Show Gist options
  • Save arbakker/dbbcd2a8e440ebaf83cc68666fc6f560 to your computer and use it in GitHub Desktop.
Save arbakker/dbbcd2a8e440ebaf83cc68666fc6f560 to your computer and use it in GitHub Desktop.
NGINX Log Headers
// /etc/nginx/headers.js
function headers_json(r) {
return JSON.stringify(r.headersIn)
}
export default {headers_json};
# /etc/nginx/nginx.conf
load_module modules/ngx_http_js_module.so;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
proxy_temp_path /tmp/proxy_temp;
client_body_temp_path /tmp/client_temp;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;
include /etc/nginx/mime.types;
default_type application/octet-stream;
js_import headers.js;
js_set $headers_json headers.headers_json;
log_format main escape=none
'\nremote_addr: $remote_addr'
'\nremote_user: $remote_user'
'\ntime_local: $time_local'
'\nrequest: $request'
'\nstatus: $status'
'\nheaders_json: $headers_json'
'\nhttp_x_forwarded_for: $http_x_forwarded_for'
'\nProxy: "$proxy_host" "$upstream_addr"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment