0

In my config file I use

location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
        access_log        off;
        expires           30d;
        root /var/www;
        }

However, I have a PHP script that generates a captcha image which does not have an ending. nginx does not display the image. What can I do to solve this?

Frank Vilea
  • 559
  • 2
  • 8
  • 16

1 Answers1

0

Make it have an ending, or have it send image headers and catch those headers in Nginx.

Aleksey Korzun
  • 276
  • 1
  • 4
  • Thanks Aleksey, how do you go about catching image headers? – Frank Vilea Jul 06 '11 at 16:35
  • Not sure about Nginx. You can also just put your Captcha image within /captcha/* and have location rule for that. – Aleksey Korzun Jul 06 '11 at 16:45
  • Hmm.. the captcha is actually dynamically generated in php and the link to it is ../captcha/?PHPSESSID=k3uml35066lcop6q4r9tf5ajk7 So there is never actually an image saved.. – Frank Vilea Jul 06 '11 at 16:51
  • So why can't you add location directive to catch /captcha/* and turn off access log/set expire. – Aleksey Korzun Jul 06 '11 at 16:53
  • 1
    @Frank Vilea If it's always dynamically generated you should just make sure PHP sets the correct content header. Nginx is just serving the PHP output and won't set any headers unless one is required per the RFC and not yet defined. – Martin Fjordvald Jul 07 '11 at 01:27