3

The default date format in nginx autoindex HTML directory listings is 19-Jun-2019. Can I change it to ISO YYYY-MM-DD format instead?

Lassi
  • 465
  • 1
  • 5
  • 10
  • 1
    You could use third party module fancyindex https://github.com/aperezdc/ngx-fancyindex. If you use debian/ubuntu you could install nginx-extras package – Alexey Ten Jun 19 '19 at 18:32

1 Answers1

3

No, it does not seem possible.

Based on the source code, the line that seems to generate the date is at https://trac.nginx.org/nginx/browser/nginx/src/http/modules/ngx_http_autoindex_module.c#L630 :

b->last = ngx_sprintf(b->last, "%02d-%s-%d %02d:%02d ",
                      tm.ngx_tm_mday,
                      months[tm.ngx_tm_mon - 1],
                      tm.ngx_tm_year,
                      tm.ngx_tm_hour,
                      tm.ngx_tm_min);

So the datetime specification is hardcoded and does not seem to be configurable. There are various other spots above or below this line that takes an assumption on the datetime final length so it is not a simple matter of changing this line in code and recompiling.

Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42
  • Thanks a lot for digging up the source code! I appreciate it. But are these really the coding practices they use in the world's foremost web server? Manual string length calculations followed by `memcpy` and `sprintf` without proper bounds checking. – Lassi Jun 19 '19 at 20:11
  • @Lassi I can agree, but note that `autoindex` is just one module, an extra feature that is not needed for core Nginx operations. – Patrick Mevzek Jun 19 '19 at 20:23
  • It seems the HTTP parser is hand-written too. So the server is secure in spite of the engineering practices, not because of them. The cowboy coders will forever rule this industry :) However, some people have fuzzed HTTP requests and no vulnerabilities were found: https://lolware.net/2015/04/28/nginx-fuzzing.html – Lassi Jun 19 '19 at 20:48