mendhak / docker-http-https-echo

Docker image that echoes request data as JSON; listens on HTTP/S, useful for debugging.
https://code.mendhak.com/docker-http-https-echo/
MIT License
621 stars 136 forks source link

Would it be possible to add TZ environment variables? #60

Open jacol84 opened 9 months ago

jacol84 commented 9 months ago

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"
mendhak commented 9 months ago

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.