【发布时间】:2009-11-15 11:37:36
【问题描述】:
我使用 Ajax 和 iframe 将图像上传到我的应用程序。在开发中,一切都像魅力一样工作。但在生产中 Nginx 突然引发 404 错误。当我查看日志时,请求从未命中 Rails 应用程序。所以我想这与我的 Nginx 配置有关(可能是 gzip 压缩)。
失败的请求被发送到“/images.js”。
关于如何解决这个问题的任何想法? Google 帮不了我...
我的 Nginx 配置:
server {
listen 80;
server_name www.myapp.de;
root /var/www/apps/myapp/current/public; # <--- be sure to point to 'public'!
passenger_enabled on;
rails_env production;
# set the rails expires headers: http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger
location ~* \.(ico|css|js|gif|jp?g|png)(\?[0-9]+)?$ {
expires max;
break;
}
gzip on;
gzip_http_version 1.0;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
gzip_buffers 16 8k;
# this rewrites all the requests to the maintenance.html
# page if it exists in the doc root. This is for capistrano?^?^?s
# disable web task
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
# Set the max size for file uploads to 10Mb
client_max_body_size 10M;
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/apps/myapp/current/public;
}
}
【问题讨论】:
标签: ruby-on-rails ajax format nginx