nginx가 파일을 업로드하지 못하고 업로드된 파일이 너무 크다는 메시지가 표시됩니다. 문제 해결 방법

王林
풀어 주다: 2020-12-10 16:07:44
앞으로
5086명이 탐색했습니다.

nginx가 파일을 업로드하지 못하고 업로드된 파일이 너무 크다는 메시지가 표시됩니다. 문제 해결 방법

문제 설명:

파일을 업로드하지 못했습니다. 파일 크기는 약 4M입니다. 업로드 프로그램은 Java이고 nginx 역방향 프록시를 통해 Fastdfs에 작성되지만 계속 실패합니다. nginx 오류 로그를 확인하면 다음 내용이 표시됩니다.

client intended to send too large body: 4134591 bytes
로그인 후 복사

(관련 권장 사항: nginx tutorial)

분석:

오류 메시지 프롬프트에 따르면 클라이언트가 보낸 본문이 너무 큽니다. nginx의 기본 클라이언트 본문 크기는 1M입니다.

공식 문서는 다음과 같습니다:

Syntax: client_max_body_size size;
Default: client_max_body_size 1m;
Context: http, server, location
Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. Please be aware that browsers cannot correctly display this error. Setting size to 0 disables checking of client request body size.
로그인 후 복사

해결책:

공식 문서에 따르면 nginx 구성 파일의 http, 서버, 위치 및 기타 구성 블록에 구성, client_max_body_size 크기를 추가하여 본문을 조정할 수 있습니다. 허용된 클라이언트 업로드 파일의 크기입니다. 0으로 설정하면 제한이 없음을 나타냅니다.

코드 예:

http {
    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;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
	
    client_max_body_size 100m;
	....
	}
로그인 후 복사

위 내용은 nginx가 파일을 업로드하지 못하고 업로드된 파일이 너무 크다는 메시지가 표시됩니다. 문제 해결 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:csdn.net
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!