Skip to content

Instantly share code, notes, and snippets.

@mnordhoff
Last active December 28, 2015 06:49
Show Gist options
  • Save mnordhoff/7459904 to your computer and use it in GitHub Desktop.
Save mnordhoff/7459904 to your computer and use it in GitHub Desktop.
# Replace blank variables with -
#
# map $foo $foo_h {
# default $foo;
# "" -;
# }
map $host $host_h { default $host; "" -; }
log_format lighttpd
'$remote_addr $host_h $remote_user [$time_local] "$request" $status '
'$body_bytes_sent "$http_referer" "$http_user_agent"';
access_log /var/log/nginx/access.log lighttpd;
# This version is a little more readable, but I haven't tested it.
# Replace blank $host with -
map $host $host_or_hyphen {
default $host;
"" -;
}
log_format lighttpd
'$remote_addr $host_or_hyphen $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$http_user_agent"';
access_log /var/log/nginx/access.log lighttpd;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment