使用 nginx 缓存 ruby on Rails 应用程序的静态文件
一段时间以来,我一直在尝试服务和服务。使用 nginx 为我的 Rails 应用程序缓存静态文件。 Rails 应用服务器运行 mongrel_cluster 并部署在与 nginx 不同的主机上。
在许多可用的讨论之后,我尝试了以下
server {
listen 80;
server_name www.myappserver.com;
ssl on;
root /var/apps/myapp/current/public;
location ~ ^/(images|javascripts|stylesheets)/ {
root /var/apps/myapp/current;
expires 10y;
}
location / {
proxy_pass http://myapp_upstream;
}
}
但是 nginx 无法找到图像并加载 css 和 js 文件。有人可以帮我吗?
我的目标是配置 nginx,使其缓存静态文件直到过期。
请建议我一些方法来实现这一目标,还是我在这里遗漏了任何一点?
I have been trying for some time to serve & cache static files for my rails app using nginx. the rails app server runs mongrel_cluster and is deployed on a different host than that of nginx.
following many of the available discussions I tried the following
server {
listen 80;
server_name www.myappserver.com;
ssl on;
root /var/apps/myapp/current/public;
location ~ ^/(images|javascripts|stylesheets)/ {
root /var/apps/myapp/current;
expires 10y;
}
location / {
proxy_pass http://myapp_upstream;
}
}
But nginx fails to find the images and to load the css and js files. Can anyone help me out here?
My aim is to configure nginx in such a way that it caches the static files till expiry.
Please suggest me some way to achieve this or am I missing any point here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿。我相信 Ezra @Engine Yard 几年前写过一篇关于此的博客文章。所有这些都是开箱即用的@安永,所以这是利用他的专业知识的一种方式。 :-)
Hey there. I believe Ezra here @ Engine Yard wrote a blog post on this years ago. All of this works out of the box @ EY, so that is one way to utilize his expertise. :-)