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?

0

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

  • Thanks Aleksey, how do you go about catching image headers? – Frank Vilea Jul 6 '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 6 '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 6 '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 6 '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 7 '11 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.