我使用nginx
和unicorn
在Ubuntu 12.04中部署了我的Rails应用程序。
在我的应用程序中,我无法上传大于10MB的文件。我检查了nginx
错误日志并找到了
client intended to send too large body
我已经Google搜索并获得了一个解决方案,我必须将client_max_body_size 25M;
添加到/etc/nginx/nginx.conf
。我这样做了,但它不起作用。请帮忙。下面添加了nginx.conf
内容:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size 25M;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/xml text/css text/comma-separated-values;
upstream app_server { server 127.0.0.1:8080 fail_timeout=0;}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
答案 0 :(得分:4)
在 nginx.conf 中,在服务器块中添加以下行: -
http {
#other configuration
server {
#other configuration
client_max_body_size 25M;
}
}
在 http block 中添加:
server {
listen 80;
client_max_body_size 25M;
server_name localurl.me;
index index.html index.htm;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_pass http://0.0.0.0:3000;
}
}