最近小编在做照片接口提交时提示 413 Request Entity Too Large (nginx 1.8),这种情况是接口请求配置的nginx的请求实体不够大导致。
Nginx默认最大能够上传1MB文件,大于1MB的文件自然无法上传,打开nginx.conf(没权限找运维人员)在http{ }中设置:client_max_body_size 50m
后面50m代表的请求实体最大为50MB。
据图配置如下
http {
include 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"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
client_max_body_size 10m; //配置最大请求实体10MB,
server {
listen 80;
server_name hereitis.cn;
location / {
root dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /here/ {
proxy_set_header Host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080;
client_max_body_size 10m;
}
}