【问题标题】:In my rails 3 app, simple_captcha doesn't display image on production mode在我的 rails 3 应用程序中,simple_captcha 在生产模式下不显示图像
【发布时间】:2018-04-13 21:10:51
【问题描述】:

simple_captcha 可以在我的开发机器上找到,但它不在我的共享托管服务器 (Dreamhost) 上。

ImageMagick 已安装并且 RMagick 在那里没问题。 有什么问题?

我检查了日志,它没有显示任何错误消息。

Started GET "/simple_captcha/0245065ca02e2f4fadc22b3f08e1357ea74221f8?time=1304535698" for 99.122.173.225 at Wed May 04 12:01:38 -0700 2011

当我输入地址(/simple_captcha/0245065ca02e2f4fadc22b3f08e1357ea74221f8?time=1304535698)时,它说“图像无法显示,因为它包含错误”。

知道有什么问题吗?

谢谢。

山姆

【问题讨论】:

    标签: ruby-on-rails captcha


    【解决方案1】:

    你试过注释掉

    config.action_dispatch.x_sendfile_header = "X-Sendfile" 
    

    行?

    在这里找到: Rails sends 0 byte files using send_file

    【讨论】:

    • 解决了这个问题。谢谢。
    【解决方案2】:

    我在运行 Ubuntu 10.10 + Nginx + Passenger 的服务器上遇到了同样的问题。

    我在这个帖子中找到了解决方案:http://www.mail-archive.com/heroku@googlegroups.com/msg06836.html

    simple_captcha 使用 send_file 将图像发送到浏览器。因此,您需要在生产环境中启用 XSendfile。你可以把这条线放在你的环境/production.rb中:

    config.action_dispatch.x_sendfile_header = "X-Sendfile"
    

    如果您使用的是 nginx,则必须改用 X-Accel-Redirect。见http://wiki.nginx.org/XSendfile

    config.action_dispatch.x_sendfile_header = "X-Accel-Redirect"
    

    【讨论】:

    • 我按照你的指示(apache 版本),我的问题仍然存在。不管怎么说,还是要谢谢你。我会继续寻找...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-05
    • 2015-11-20
    • 2016-05-21
    • 2011-04-22
    • 2020-01-07
    相关资源
    最近更新 更多