我需要编辑AWS ELB环境的nginx配置,以便它接受最大为50MB的有效负载(请求主体)。
默认的nginx有效负载限制为1MB。
我研究了许多问题和答案,发现了: https://stackoverflow.com/a/40745569
但是我不确定如何访问ELB环境背后的nginx配置文件。
我还尝试了以下AWS文档: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-nginx.html
但是我仍然无法从有效载荷大于1M的发布请求中获得响应。 (该服务器是Node.js服务器)
所以,请让我知道如何将nginx的最大有效负载大小从默认的1M更改为50MB。请注意,nginx在AWS ELB环境中工作。
附录1:这是我使用的.ebextensions / nginx / nginx.conf文件代码:
user nginx;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 33282;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
include conf.d/*.conf;
map $http_upgrade $connection_upgrade {
default "upgrade";
}
server {
listen 80 default_server;
root /var/app/current/public;
location / {
}
location /api {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
access_log /var/log/nginx/access.log main;
client_header_timeout 60;
client_body_timeout 60;
keepalive_timeout 60;
gzip off;
gzip_comp_level 4;
# Include the Elastic Beanstalk generated locations
include conf.d/elasticbeanstalk/01_static.conf;
include conf.d/elasticbeanstalk/healthd.conf;
client_max_body_size 100M; #100mb
}
client_max_body_size 100M; #100mb
}
附录2。我已经将这两行添加到Node.js Express应用程序中:
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: "50mb", extended: true, parameterLimit:50000}));