首先,我很困惑。我已經ssh'ed到我們的彈性beanstalk實例來細讀nginx所在的位置等等,而且看起來我找不到它。如何通過ebextensions配置文件添加nginx緩存控制標頭?
顯然,執行curl命令產量頭,如:
Content-Encoding: gzip
Content-Type: text/css
Date: Wed, 23 Oct 2013 20:33:53 GMT
Last-Modified: Wed, 23 Oct 2013 18:59:04 GMT
Server: nginx/1.2.3
transfer-encoding: chunked
Connection: keep-alive
所以我認爲nginx的是那裏的地方。我試圖發現正確的位置,所以我可以通過ebextensions注入一個配置文件。
從本質上講,我想確保我在遙遠的未來,這似乎並沒有被工作集高速緩存控制:
03-nginx.config:
files:
"/etc/nginx/conf.d/custom.conf" :
mode: "000777"
owner: ec2-user
owner: ec2-user
content: |
location ~ ^/assets/ {
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
看來,nginx
通過運行。
[[email protected] support]$ pwd
/var/app/support
[[email protected] support]$ ls pids
passenger.pid passenger.pid.lock
[[email protected] support]$ cat pids/passenger.pid
1781
[[email protected] support]$ ps -eaf | grep 1781
root 1781 1 0 Sep25 ? 00:00:00 nginx: master process /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/nginx-1.2.3/sbin/nginx -c /tmp/passenger-standalone.1704/config -p /tmp/passenger-standalone.1704/
webapp 1782 1781 0 Sep25 ? 00:00:57 nginx: worker process
ec2-user 26387 25743 0 10:53 pts/0 00:00:00 grep 1781
更新 我使用的鐵軌側CloudFront的配置此配置。儘管標題不符合理想的建議,但總比沒有好。
#--------------------------------------------------------------------------------
# CDN
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# http://thediscoblog.com/blog/2013/05/01/the-rails-cloudfront-and-heroku-performance-hat-trick/
# http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html
# http://www.mnot.net/cache_docs/
# Check with http://redbot.org/
# - set asset host
#--------------------------------------------------------------------------------
config.action_controller.asset_host = "http://cdn.staging.acme.com"
config.assets.compress = true # Compress JavaScripts and CSS
config.assets.compile = false # Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.digest = true # Generate digests for assets URLs
# must do this so we can inject the proper cache-control headers for cloudfront, served very few times anyways...
#config.serve_static_assets = true
config.static_cache_control = "public, max-age=#{1.year.to_i}"
仍然懸而未決的問題: 我缺少什麼?我應該使用什麼位置爲獨立乘客注入額外的nginx
配置?
似乎''nginx'作爲'passenger-standalone'的一部分是不可配置的......但我仍然需要爲這些頭文件提供正確的'cloudfront' cdn緩存。 – kross
不知道乘客,但這個答案可能有所幫助http://stackoverflow.com/questions/18908426/increasing-client-max-body-size-in-nginx-conf-on-aws-elastic-beanstalk – mrmagooey
@kross did你有沒有找到解決這個問題的方法?我處於從passgenger gem(並存儲在/ tmp)中創建原始配置的位置,但我不知道是否需要推送整個配置,或者是否可以放入覆蓋片段/包括。 – chrisp