Answer the question
In order to leave comments, you need to log in
Why is captcha not working in nginx?
Good afternoon!
Faced such a problem, dynamic capthca does not work in nginx. Previously, the site worked on apache + php was transferred to nginx + php-fpm.
The problem is that there is a captcha that is dynamically generated using the php controller is not displayed on the site, the following is in the logs:
2014/02/11 14:12:37 [error] 3029#0: *1 open() "/var/www/site.ru/captcha.jpg" failed (2: No such file or directory), client: 37.110.25.111, server: site.ru, request: "GET /captcha.jpg?1392145982456 HTTP/1.1", host: "www.site.ru", referrer: "http://www.site.ru/qna/"
location / {
index index.php;
#auth_basic "Members Only";
#auth_basic_user_file /etc/nginx/htpasswd;
rewrite ^/image /image.php last;
rewrite ^/web/(.*) /web/$1 last;
rewrite ^/receiver.html /receiver.html last;
rewrite ^/ /index.php last;
#rewrite ^/captcha.jpg /controller/common.php last;
#try_files $uri $uri/ /index.php;
}
#location /captcha.jpg {
#}
# Images and static content is treated different
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|xml|ttf|woff|eof|swf)$ {
access_log off;
expires 100d;
}
Answer the question
In order to leave comments, you need to log in
Something like this (not tested)
location = /captcha.jpg {
//тут либо пхп обработчик либо реврайт
rewrite ^/captcha.jpg /controller/common.php last;
}
What a nightmare you have in the config. You read to doc Sysoev. It is in Russian and very clearly written
. I have done something like this:
...
location = /path/to/capcha.php {
include php5_provider;
}
location = /capcha {
rewrite ^ /path/to/capcha.php?$uri last;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question