登录
注册
node.js 学习社区
nginx express 上传文件的限制大小

这回呢

2017-08-11 11:44

express 代码

var express     = require('express');
var bodyParser  = require('body-parser');
var multiparty = require('connect-multiparty');
app.use(multiparty());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json({limit:'10mb'}));
nginx 代码

server {
        listen  80;
        server_name  test.baidu.com;
        client_max_body_size 10m;
        location / {
                        proxy_http_version  1.1;
                        proxy_pass          http://127.0.0.1:3000;
                        proxy_set_header    X-Real-IP $remote_addr;
                        proxy_connect_timeout 60;
                        proxy_send_timeout 60;
                        proxy_read_timeout 60;
                        proxy_set_header    Connection "";
                        proxy_set_header    Host $http_host;
                        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}


app.use(bodyParser.json({limit:'10mb'}));

client_max_body_size 10m;


回复 · 0

发表回复

你可以在回复中 @ 其他人