这是一个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中:
原文链接:https://www.f2er.com/nginx/434625.htmlfiles:
"/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