襄城县城乡建设管理局网站,高级网站设计,龙岗网站(建设深圳信科),安安互联怎么上传网站问题描述
我在上传一个图片文件的时候#xff0c;收到 Nginx 报错#xff1a;
413 Request Entity Too Large
问题原因
Nginx 默认上传文件大小是 1 MB#xff0c;如果上传过大文件#xff0c;会报上面的错误。
解决方法
需要修改nginx的配置文件。以下是如何修改的步…问题描述
我在上传一个图片文件的时候收到 Nginx 报错
413 Request Entity Too Large
问题原因
Nginx 默认上传文件大小是 1 MB如果上传过大文件会报上面的错误。
解决方法
需要修改nginx的配置文件。以下是如何修改的步骤
1、打开nginx的配置文件。在大多数Linux系统上nginx的配置文件通常位于/etc/nginx/nginx.conf或/etc/nginx/conf.d/default.conf。你可以使用文本编辑器如vi或nano打开该文件。
2、在配置文件中找到http块该块定义了nginx服务器的全局配置。
3、在http块中添加或修改以下配置项
client_max_body_size 8m; # 设置允许的最大请求体大小为8MB
样例配置如下
[rootweb01 ~]# cat /application/nginx/conf/nginx.conf
worker_processes 2;
worker_cpu_affinity 0101 1010;
error_log logs/error.log;#配置Nginx worker进程最大打开文件数
worker_rlimit_nofile 65535;user www www;
events {#单个进程允许的客户端最大连接数worker_connections 20480;#使用epoll模型use epoll;
}
http {include mime.types;default_type application/octet-stream;#sendfile on;#keepalive_timeout 65;#访问日志配置log_format main $remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for;#虚拟主机include /application/nginx/conf/extra/www.conf;include /application/nginx/conf/extra/blog.conf;include /application/nginx/conf/extra/bbs.conf;include /application/nginx/conf/extra/edu.conf;include /application/nginx/conf/extra/phpmyadmin.conf;include /application/nginx/conf/extra/status.conf;#nginx优化----------------------#隐藏版本号server_tokens on;#优化服务器域名的散列表大小 server_names_hash_bucket_size 64;server_names_hash_max_size 2048;#开启高效文件传输模式sendfile on;#减少网络报文段数量#tcp_nopush on;#提高I/O性能tcp_nodelay on;#连接超时 时间定义 默认秒 默认65秒keepalive_timeout 60;#读取客户端请求头数据的超时时间 默认秒 默认60秒client_header_timeout 15;#读取客户端请求主体的超时时间 默认秒 默认60秒client_body_timeout 15;#响应客户端的超时时间 默认秒 默认60秒send_timeout 25;#上传文件的大小限制 默认1mclient_max_body_size 8m;
}