The captcha image is not work in my production env but devlopment is ok
I write a rails app in my local machine(OSX 10.6.6,Rails3.0.1,WEB开发者_如何学编程rick)
. Simple-captcha works fine. When I push the app to my web server (Centos5.5,Rails 3.0.1,Phusion Passenger version 3.0.2)
no error is found but the image does not display in the site.
I notice /tmp
has some files like simple_captcha20110324-19769-1bf4hah.jpg
. I open it in my server, the image is captcha image. So I think the captcha generate is working, but something wrong in the production environment. I trace the process and found ioctl(27, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffc3fad550) = -1 ENOTTY (Inappropriate ioctl for device)
. Do you have any suggestions?
strace info:
...
stat("/tmp/simple_captcha20110324-3073-14fnzd6.jpg", {st_mode=S_IFREG|0600, st_size=1808, ...}) = 0
stat("/tmp/simple_captcha20110324-3073-14fnzd6.jpg", {st_mode=S_IFREG|0600, st_size=1808, ...}) = 0
geteuid() = 500
getegid() = 500
getuid() = 500
getgid() = 500
access("/tmp/simple_captcha20110324-3073-14fnzd6.jpg", R_OK) = 0
open("/tmp/simple_captcha20110324-3073-14fnzd6.jpg", O_RDONLY) = 27
ioctl(27, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffc3fad550) = -1 ENOTTY (Inappropriate ioctl for device)
brk(0x63b0000) = 0x63b0000
write(3, "\n\nStarted GET \"/simple_captcha/e"..., 133) = 133
clock_gettime(CLOCK_REALTIME, {1300937319, 188732000}) = 0
writev(11, [{"Status: ", 8}, {"200", 3}, {"\r\n", 2}, {"X-Powered-By: ", 14}, {"Phusion Passenger (mod_rails/mod"..., 44}, {"\r\n", 2}, {"Content-Disposition", 19}, {": ", 2}, {"inline; filename=\"simple_captcha"..., 37}, {"\r\n", 2}, {"Content-Transfer-Encoding", 25}, {": ", 2}, {"binary", 6}, {"\r\n", 2}, {"Content-Type", 12}, {": ", 2}, {"image/jpeg", 10}, {"\r\n", 2}, {"Cache-Control", 13}, {": ", 2}, {"private", 7}, {"\r\n", 2}, {"X-UA-Compatible", 15}, {": ", 2}, {"IE=Edge,chrome=1", 16}, {"\r\n", 2}, {"Set-Cookie", 10}, {": ", 2}, {"_newuser_session=BAh7CEkiD3Nlc3N"..., 275}, {"\r\n", 2}, {"X-Sendfile", 10}, {": ", 2}, ...], 39) = 623
shutdown(11, 1 /* send */) = 0
close(11) = 0
...
UPDATE:
I think some bug in https://github.com/galetahub/simple-captcha maybe. I chose this branch https://github.com/kares/simple_captcha all env work fine!
https://github.com/galetahub/simple-captcha uses send_file (from rails streaming api) to stream the captcha image. Did you enable mod-xsendfile in your apache configuration?
You should try setting config.serve_static_assets = true in your config/environments/production.rb file.
By default, rails does not serve static content in production mode, for performance reasons. Your webserver should be configured to do that.
if I remember captcha has different keys for development and production environments, have you already checked it out?
精彩评论