Nginx shows wrong time/timezone
To change the timezone you can run the following command in your instance:
sudo dpkg-reconfigure tzdata
and then choose your preferred timezone.
Firstly, you need to set your system timezone. You can use timedatectl list-timezones
to get the names.
sudo timedatectl set-timezone Europe/Moscow
Secondly, set autoindex_localtime directive autoindex_localtime on;
in nginx config file for your site, for example /etc/nginx/sites-avaliable/default
. Put the directive before autoindex on;
server {
listen 80;
listen [::]:80;
root /var/www/dir;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
autoindex_localtime on;
autoindex on;
}
By default, nginx outputs the directory index in UTC time. If you want it to display the time in your local timezone, you should set the autoindex_localtime directive to on.
autoindex_localtime on