docker-http-https-echo icon indicating copy to clipboard operation
docker-http-https-echo copied to clipboard

Would it be possible to add TZ environment variables?

Open jacol84 opened this issue 1 year ago • 1 comments

I don't know how to set the time zone variable, an example that works is mariadb:latest, amazoncorretto:21

this is example docker-compose.yaml:

version: '3.8'
  server-a:
    container_name: server-a
    image: mendhak/http-https-echo
    environment:
      TZ: Europe/Warsaw
    ports:
      - "8091:8080"

jacol84 avatar Nov 30 '23 13:11 jacol84

Looks like the morgan library only outputs UTC, based on this part of the README. That would explain why the TZ just gets ignored.

It's possible to use a third party library to format the date respecting the timezone, as seen in this article.

However, the date would need to match the Apache Common Log Format (CLF) format which is: "10/Oct/2000:13:55:36 +0000".

In the code currently the combined line format is:

:remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"

So I think it would require replacing the :date[clf] bit with a custom date token.

mendhak avatar Dec 03 '23 19:12 mendhak