【发布时间】:2010-11-13 18:15:01
【问题描述】:
我正在尝试从 Apache 迁移到 nginx,在这两个实例中都使用Passenger 来托管 Rails 应用程序。该应用程序接受一个请求,这是一个图像 - 如果图像存在于 /system/logos/$requestedimage 那么它应该得到服务,或者它应该被允许在需要时点击 Rails 应用程序来生成它(然后它在哪里缓存到 /system/logos)。
在 Apache 中,我使用了以下内容:
RewriteCond %{DOCUMENT_ROOT}/system/logos/%{REQUEST_FILENAME} -f
RewriteRule ^/(.*)$ http://assets.clg.eve-metrics.com/system/logos/$1
这很好用。资产。子域是另一个子域,但具有相同的根,只是禁用了乘客,专门设置用于托管静态文件(过期)。
在 nginx 中,我使用以下内容:
server {
listen 80;
passenger_enabled on;
server_name clg.eve-metrics.com www.clg.eve-metrics.com;
root /opt/www/clg/current/public;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml text/css application/javascript;
gzip_disable msie6;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
if (-f $document_root/system/logos$request_filename) {
rewrite ^/(.*)$ http://assets.clg.eve-metrics.com/system/logos/$1 break;
}
}
这不太好用。事实上。它永远不会重定向到缓存路径,也永远不会命中 Rails 应用程序。这就像 nginx 假设它是一个静态资产,所以不将它传递给乘客。有没有办法阻止这种行为,让它影响应用程序?
【问题讨论】:
标签: ruby-on-rails ruby apache nginx passenger