带乘客的nginx不处理静态资产

时间:2011-12-14 16:53:44

标签: ruby-on-rails nginx passenger

我有rails app运行有帮助的nginx和乘客,我想添加静态页面(conteins代码覆盖率分析工具 - simplecov)。 Localy这个工作正常(没有乘客),但在服务器上这不起作用。 我的nginx.conf:

    #user  nobody;
worker_processes  1;


events {
    worker_connections  1024;
    #speed up for linux 2.6+
    use epoll;
}


http {

    passenger_root /home/demo/.rvm/gems/ruby-1.9.3-p0@gm/gems/passenger-3.0.9;
    passenger_ruby /home/demo/.rvm/wrappers/ruby-1.9.3-p0@gm/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
       listen 80;
       server_name *.dev.mysite.com;
       root /var/www/projects/mysite/qa/current/public;
       passenger_enabled on;

       rails_env qa;

       charset utf-8;
       error_log  /var/www/projects/mysite/qa/shared/log/host.error.log;
    }

    #Coverage code tool (SimpleCov gem)
    server {
       listen 4444;
           server_name coverage.mysite.com;
       location / {
           root /var/lib/jenkins/jobs/WebForms/workspace/coverage;
           index index.html index.htm;
       }
    }

    #Yard server
    server {
       listen 5555;
       server_name yard.mysite.com;
       location / {
         proxy_pass http://127.0.0.1:8808;
       }}}

当我试图访问coverage.mysite.com:4444时没有收到任何结果。

1 个答案:

答案 0 :(得分:2)

我想我记得在我的一个rails应用程序中遇到类似的东西。

您是否尝试过评论并取消注释下面的行?:

# in config/environments/production.rb

  # Specifies the header that your server uses for sending files
  #config.action_dispatch.x_sendfile_header = "X-Sendfile"

  # For nginx:
  config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

它应该在第12到第16行附近的顶部附近。

试试,然后在浏览器中重新部署并测试。