Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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