nginx 업로드 용량 제한 설정 | nginx 업로드 용량 늘리기 (리눅스 -우분투) > 코딩 스토리

nginx 업로드 용량 제한 설정 | nginx 업로드 용량 늘리기 (리눅스 -우분투)

본문

서버에 파일을 올리는데 413 Request Entity Too Large nginx/1.18.0 (Ubuntu)가 뜬다, 왜 그런 것일까?

그건 nginx(웹서버)의 파일 업로드 용량 제한이 걸려있기 때문이다.

보통 설정하지 않으면 기본값으로 최대 1M를 업로드할 수 있고, 이후 부터는 위와 같은 오류가 발생한다.

이렇게 업로드 용량을 제한한 까닭은 서버에 악의적으로 고용량의 파일을 업로드하는 것을 막기 위해서라고 한다.

이제 해결방법을 알아보겠다.


nginx 설정파일 수정하기:

[code]sudo vi  /etc/nginx/nginx.conf[/code]를 입력


파일에 들어갔다면, 수정하기 버튼인 i를 누르고


/etc/nginx/nginx.conf:


events {

worker_connections 768;

# multi_accept on;

}


http {


##

# Basic Settings

##

sendfile on;

tcp_nopush on;

types_hash_max_size 2048;

# server_tokens off;


# server_names_hash_bucket_size 64;

# server_name_in_redirect off;


include /etc/nginx/mime.types;

default_type application/octet-stream;


##

# SSL Settings

##


ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE

ssl_prefer_server_ciphers on;


##

# Logging Settings

20,1-8Top

##

# Basic Settings

##


sendfile on;

tcp_nopush on;

types_hash_max_size 2048;

# server_tokens off;


# server_names_hash_bucket_size 64;

# server_name_in_redirect off;


include /etc/nginx/mime.types;

default_type application/octet-stream;


##

# SSL Settings

##


  19,1-817%

##

# Basic Settings

##


sendfile on;

tcp_nopush on;

types_hash_max_size 2048;

# server_tokens off;


# server_names_hash_bucket_size 64;

# server_name_in_redirect off;


include /etc/nginx/mime.types;

default_type application/octet-stream;


##

# SSL Settings

##

  19,26-3317%

##

# Basic Settings

##


sendfile on;

tcp_nopush on;

types_hash_max_size 2048;

# server_tokens off;


# server_names_hash_bucket_size 64;

# server_name_in_redirect off;


include /etc/nginx/mime.types;

default_type application/octet-stream;


##

# SSL Settings

##

위의 코드 중

http {


##

# Basic Settings

##

밑에 [code]client_max_body_size 원하는 용량;[/code]를 입력한다.


예시

[code]client_max_body_size 25M;[/code]

nginx에서의 최대 업로드 용량은 25M가 돠는 것이다.


작성을 다했다면 


esc 버튼을 누르고


[code]:wq[/code]를 하여 저장하고 나가기를 하자


마지막으로 nginx 재시작하기

[code]sudo systemctl restart nginx[/code]


재시작 명령어가 작동하지 않으면?

https://dsclub.kr/bbs/board.php?bo_table=code&wr_id=321

참고

좋아요127 이 글을 좋아요하셨습니다
url 복사 카카오톡 공유 라인 공유 페이스북 공유 트위터 공유

카테고리 분류 학습 시스템 (총 0개 학습됨)

예측 카테고리: 국제 (랜덤 - 학습 데이터 없음)

이 분류가 맞나요? 학습시켜주세요!

2kat님의 댓글

no_profile 2kat쪽지보내기 자기소개 아이디로 검색 전체게시물 아이피 (220.♡.000.000) 작성일

좋네요

😶
❤️
😂
😅
😮
😡
🥵
  • RSS
  • _  글쓰기 글쓰기
전체 302건
게시물 검색

접속자집계

오늘
1,211
어제
4,460
최대
42,418
전체
943,899