ruby-on-rails – 如何使用puma / nginx在资产管道中提供不属于/ public的资产?

这是一个AWS问题,我使用的是 Ruby 2.2(Puma)平台.

我编译的资产(in / public / assets)按预期方式提供. / public中的其他资产未被送达(404).

我在哪里配置?这是一个Nginx问题吗?还是美洲狮问题?

还是这只是一个AWS图像问题?

这是一个实例(robots.txt应该从根):
http://staging.us-west-2.elasticbeanstalk.com/public/robots.txt

还值得一提的是,默认的Passenger平台图像是开箱即用的.

解决方法

如果它帮助任何人,或有人知道如何改进它,这里是Nginx配置,终于得到它为我工作.在/.ebextensions/01_files.config中:
files:
    "/etc/Nginx/conf.d/webapp_healthd.conf" :
        mode: "000755"
        owner: root
        group: root
        content: |
            upstream my_app {
              server unix:///var/run/puma/my_app.sock;
            }

            log_format healthd '$msec"$uri"'
                            '$status"$request_time"$upstream_response_time"'
                            '$http_x_forwarded_for';

            server {
              listen 80;
              server_name _ localhost; # need to listen to localhost for worker tier
              root /var/app/current/public;

              if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
                set $year $1;
                set $month $2;
                set $day $3;
                set $hour $4;
              }

              access_log  /var/log/Nginx/access.log  main;
              access_log /var/log/Nginx/healthd/application.log.$year-$month-$day-$hour healthd;

              try_files $uri/index.html $uri @my_app;

              location @my_app {
                proxy_pass http://my_app; # match the name of upstream directive which is defined above
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              }

              location /assets {
                alias /var/app/current/public/assets;
                gzip_static on;
                gzip on;
                expires max;
                add_header Cache-Control public;
              }
            }
    "/opt/elasticbeanstalk/hooks/appdeploy/post/03_restart_Nginx.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
            #!/usr/bin/env bash
            rm /etc/Nginx/conf.d/webapp_healthd.conf.bak
            rm /etc/Nginx/conf.d/custom.conf            
            service Nginx restart

相关文章

以下代码导致我的问题: class Foo def initialize(n=0) @n = n end attr_accessor :n d...
这是我的spec文件,当为上下文添加测试“而不是可单独更新用户余额”时,我得到以下错误. require 's...
我有一个拦截器:DevelopmentMailInterceptor和一个启动拦截器的inititializer setup_mail.rb. 但我想将...
例如,如果我有YAML文件 en: questions: new: 'New Question' other: recent: ...
我听说在RSpec中避免它,let,let !,指定,之前和主题是最佳做法. 关于让,让!之前,如果不使用这些,我该如...
我在Rails中使用MongoDB和mongo_mapper gem,项目足够大.有什么办法可以将数据从Mongoid迁移到 Postgres...