Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How get logs for direct requests for jpg images in NGINX?

I want direct requests for jpg images files to be logged in access.log.
For example, someone directly accesses the image saved in my wordpress:

https://www. my domain /wp-content/uploads/2021/07/image.jpg

How can I see it in the log record? I have removed access_log off and it stays like this. However, direct request logs to jpg files are not collected.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires    +60d;
}

>Solution :

Use access_log within the location block:

location ~ \.jpg$ {
  access_log /var/log/nginx/...;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading