2010-12-06 2 views
12

내 사이트에 파일을 업로드하려고하면 Nginx "413 Request Entity Too Large"오류가 발생하지만 nginx.conf 파일에 이미 최대 크기가 명시되어 있습니다. 약 250MB 였고 php.ini 파일의 최대 파일 크기도 변경했습니다. (예, 프로세스를 다시 시작했습니다). 오류 로그 나에게주는이 :Nginx 오류 413

2010년 12월 6일 4시 15분 6초 [오류] 20124 # 0 : 1,144,149 바이트, 클라이언트 : 너무 큰 몸을 보내기위한 * 11975 클라이언트 60.228.229.238 서버 : www.x.com는 요청 : "POST 업로드/HTTP/1.1", 호스트 : "x.com", 참조 자 : "http://x.com/"

로 내가 아는 한 1144149 바이트는 250MB가 아닙니다 ... 여기에 뭔가가 있습니까?

user nginx; 
worker_processes 8; 
worker_rlimit_nofile 100000; 

error_log /var/log/nginx/error.log; 
#error_log /var/log/nginx/error.log notice; 
#error_log /var/log/nginx/error.log info; 

pid  /var/run/nginx.pid; 


events { 
    worker_connections 1024; 
    use epoll; 
} 


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"'; 

    access_log /var/log/nginx/access.log main; 

    sendfile  on; 
    client_max_body_size 300M; 
    tcp_nopush  on; 
    tcp_nodelay  on; 
    server_tokens off; 
    gzip   on; 
    gzip_static  on; 
    gzip_comp_level 5; 
    gzip_min_length 1024; 
    keepalive_timeout 300; 
    limit_zone myzone $binary_remote_addr 10m; 

    # Load config files from the /etc/nginx/conf.d directory 
    include /etc/nginx/sites/*; 
} 

그리고 사이트의 가상 호스트 :

여기 기본 Nginx에의 설정입니다

server { 
    listen  80; 
    server_name www.x.com x.com; 

    access_log /var/log/nginx/x.com-access.log; 

    location/{ 
     index index.html index.htm index.php; 
     root /var/www/x.com; 

     if (!-e $request_filename) { 
      rewrite ^/([a-z,0-9]+)$ /$1.php last; 
      rewrite ^/file/(.*)$ /file.php?file=$1; 
     } 

     location ~ /engine/.*\.php$ { 
      return 404; 
     } 

     location ~ ^/([a-z,0-9]+)\.php$ { 
      fastcgi_pass 127.0.0.1:9000; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include  fastcgi_params; 
     } 
    } 
} 
+0

변경 한 nginx 구성 설정을 인용해야합니다. –

+0

좋아요. – EJay

답변

11

당신의 nginx 빌드의 버전을 모른 채하고 무엇이 어려운 차종으로 만들어진 모듈, 하지만 다음을 시도해보십시오.

  1. 고객의 최대 복사 수는 300M입니다. client_max_body_size 300M; 가상 호스트 설정의 위치/{} 부분에 줄을 긋습니다. 기본 (1 MB) 제대로 무시하는지 잘 모르겠습니다.

  2. nginx_upload_module을 사용하고 있습니까? 그렇다면 upload_max_file_size가 300MB인지 확인하십시오. 당신의 구성에 줄을.

-1
나는 또한 당신이 * .PHP 위치 핸들러 계단식 수준에서 "낮은"하나가되는

location ~ ^/([a-z,0-9]+)\.php$ { 

에서 그것을 정의 할 수 있음을 추가

, 그것은 있는지 확인하는 쉬운 방법이 될 것입니다 문제는 귀하의 nginx 구성 또는 모듈에서 비롯됩니다.

413 오류 "본문이 너무 큼"은 실제로 NGinx 오류이기 때문에 PHP에서 오지는 않습니다.

+0

왜 내가이 대답에 downvoted 모르겠어요? 설명해 주겠다고? – nembleton

1

내 설치했다 :

php.ini의

... 
upload_max_filesize = 8M 
... 

... 
client_max_body_size 8m; 
... 

nginx.conf이 업로드되었을 때의 nginx 오류 413을 보여 주었다.

그때 나는 생각했다 : 나는 따라서,의 nginx는이 upload_max_filesize보다 큰 값으로 설정 client_max_body_size, 오류 413을 보여주지 않을 것이다 :

php.ini의

... 
upload_max_filesize = 8M 
... 

의 nginx.conf

... 
client_max_body_size 80m; 
... 

무슨 일이 일어 났습니까?

80MB보다 작은 파일을 업로드하면 nginx에서 413 오류가 표시되지 않지만 파일 크기가 최대 8MB이면 PHP에서 오류가 표시됩니다.

이 문제는 해결되었지만 누군가가 80MB보다 큰 파일을 업로드하면 오류 413이 발생합니다. nginx 규칙.

+0

client_max_body_size 64m를 추가했습니다. conf의 http {} 부분에 다시 시작하면 성공했습니다! 감사! – flunder

+0

이 문제가 해결되었습니다. 나는 내 노드 서버의 body parser가 문제라고 생각했지만 nginx에서이 라인을 설정하는 것을 완전히 잊었다. – SMT