Ruby on rails 如何通过/assets的elastic beanstalk上的nginx设置

Ruby on rails 如何通过/assets的elastic beanstalk上的nginx设置,ruby-on-rails,nginx,config,amazon-elastic-beanstalk,assets,Ruby On Rails,Nginx,Config,Amazon Elastic Beanstalk,Assets,堆栈:ElasticBean、Ruby 2.1、Puma、Rails 3 nginx的EB默认配置是将/assets请求定向到位置:app\u path/public/assets。我们需要将/assets作为请求定向到应用程序,比如说myapp.elasticbeanstalk.com/products。换句话说,我们的应用程序在db中有资产表、资产模型和路由。rb定义资产资源 我尝试了下面的hook/config,但没有成功。这是一个长期错误 # .ebextensions/z_assets

堆栈:ElasticBean、Ruby 2.1、Puma、Rails 3

nginx的EB默认配置是将/assets请求定向到位置:app\u path/public/assets。我们需要将/assets作为请求定向到应用程序,比如说myapp.elasticbeanstalk.com/products。换句话说,我们的应用程序在db中有资产表、资产模型和路由。rb定义资产资源

我尝试了下面的hook/config,但没有成功。这是一个长期错误

# .ebextensions/z_assets.conf

files:
"/etc/nginx/conf.d/z_assets.conf":
  mode: "000755"
  owner: root
  group: root  
  content: |   
    server {
      listen 80;
      server_name _ localhost; # need to listen to localhost for worker tier
      location /assets {
        proxy_pass http://my_app/assets; 
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
    }

为什么你认为nginx会干扰你的路线?nginx只是一个代理,因此它遵守rails服务器(puma)的任何操作。是的,它确实会出错,我们必须添加位置^~assets/{gzip_static on;expires max;add_header Cache Control public;}以使静态资产正常工作。我也在试图找到一个合适的方法来做到这一点