[nginx] 413 Request Entity Too Large 오류

by 스뎅(thDeng) on

nginx로 reverse proxy 를 사용할 때, 용량이 큰 파일을 업로드하면 413 Request Entity Too Large 라는 메시지를 볼 수 있다.

413 Request Entity Too Large

client_max_body_size 설정 때문이고, 너무 큰 사이즈의 request를 보내지 못 하도록 제한을 걸 수 있다. 기본값은 1MB이다. request의 Content-Length 헤더값이 여기 설정된 값을 넘을 수 없다. POSTPUT 등의 request 사이즈 제한을 할 수도 있지만, 보통 악의적으로 큰 용량의 파일을 업로드해서 디스크를 가득 채우는 경우를 방지하는데 사용되지 않을까 싶다.

nginx.conf 파일에서 http, server, location에 설정이 가능하다.

http {
    client_max_body_size 5M;

    ...
}

설정을 해주지 않으면 기본값은 1m이고, 제한을 두지 않으려면 0으로 설정하면 된다.

Syntax: client_max_body_size size;
Default: client_max_body_size 1m;
Context: http, server, location

nginx.conf 파일을 수정하고, 재시작해주면 끗

$ sudo service nginx reload

참고

별도로 명시하지 않을 경우, 이 블로그의 포스트는 다음 라이선스에 따라 사용할 수 있습니다: Creative Commons License CC Attribution-NonCommercial-ShareAlike 4.0 International License