Reputation: 5297
I am running nginx with default log format
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
It prints the access log in following format
1.2.3.4 - - [27/Mar/2021:09:39:43 +0000] "GET /text.txt HTTP/1.1" 200 315 "-" "curl/7.55.1" "-"
However I want the logs to print time in UTC +05:30
which is not the local time of the server. I tried adding env "TZ=Asia/Kolkata";
at the top of nginx.conf
but it didn't work. Please suggest how to do this.
Upvotes: 1
Views: 3849
Reputation: 339
You can set up a volumeMount to use the same as the Hostnode:
spec:
volumes:
- name: date-config
hostPath:
path: /etc/localtime
containers:
volumeMounts:
- name: date-config
mountPath: /etc/localtime
Upvotes: 0
Reputation: 21
Regarding setting timezone in Nginx logs: Works fine; just need to set the "TZ" environment variable for nginx daemon (e.g. in the script that launches it). Or if you're using Docker, set it in the Dockerfile (or in the "environment" in docker-compose.yml file if you're using that).
Upvotes: 2