【发布时间】:2012-08-04 20:59:23
【问题描述】:
我有一个 Rails 网络应用程序,它在动态静态 url 下有静态文件。例如:
/projects/1/attachments/some_file.xls
我想设置 Nginx 重定向到服务器上的静态文件:
/public/attachments/1/some_file.xls
其中 1 是动态项目 ID。
location block 和 rewrite 语句如何查找 Nginx 配置文件?
更新
我在下面标记了一个答案,因为它回答了我最初的问题。尽管在我的情况下不需要重写我的项目附件 url。我忘记了我已经在 Rails 视图 erb 中重新映射了 url。
我的真正目标是阻止 Thin 将缓存响应标头添加到我的附件文件中。最终,我可以通过添加如下附件的位置来使用 Nginx 来防止这种情况:
location /attachments/ {
expires off;
add_header Pragma "no-cache";
add_header Cache-Control "no-cache, no-store";
access_log off;
break;
}
【问题讨论】:
标签: rest configuration url-rewriting nginx static-files