Nginx上传文件500

前言

今天使用nginx做负载,在上传图片时,一直报500错误(Internal Server Error 500),
开始已为是程序问题,但是在本地上传是没有问题的。
所以就往nginx的配置方面想了

一、原来的配置

 #user              root;
worker_processes  1;
worker_rlimit_nofile 102400;
events {
	worker_connections  65535;
   use epoll;
   multi_accept on;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '[$content_type]--[$remote_addr] -$remote_user [$time_local] "[$request]" '
   '[$status] $body_bytes_sent [$request_body] "$http_referer" '
   '"$http_user_agent" "$http_x_forwarded_for"';
	 sendfile        on;
    tcp_nopush     on;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 8m;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
   fastcgi_read_timeout 300;
   fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
    fastcgi_intercept_errors on;
	proxy_headers_hash_max_size 51200;
	proxy_headers_hash_bucket_size 6400;
	proxy_buffer_size 128k;
	proxy_buffers   32 128k;
	proxy_busy_buffers_size 128k;
    #keepalive_timeout  0;
    keepalive_timeout  10;
    tcp_nodelay on;
    server_tokens off;
    gzip  on;
    gzip_min_length  1k;
   gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml application/json text/json text/xml;
   gzip_vary on;
    #sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    #keepalive_timeout  65;
   #gzip  on;
    #Load config files from the /etc/nginx/conf.d directory
   #The default server is in conf.d/default.conf
    include /root/nginx/conf.d/*.conf;
	}

二、解决方案

1、方案一

(1)在/etc/security/limits.conf 添加配置

    soft nofile 65535
    hard nofile 65535

(2)在nginx中配置

worker_rlimit_nofile 65535

(我原配置也有配), 结果没有用

2、方案二

(1)在nginx上配置

client_body_buffer_size #使用默认设置,8k或者16k
client_header_buffer_size #设置得比较大

我的原配置也有配置,这也没解决我的问题

3、方案三

修改nginx中user,我这里修改为root,结果令我意外的是,居然可以上传了,至此解决了我得问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值