서버 점검 안내

dsclub은 서비스의 안정성과 성능 향상을 위해
매일 04시 30분에 정기 점검이 진행됩니다.

점검 시간: 오전 4시 30분 ~ 4시 35분

해당 시간 동안 일시적으로 서비스에 접속이 불가능하오니, 양해 부탁드립니다.

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

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

페이지 정보

작성자 profile_image tak2 (223.♡.178.77) 작성일 23-07-30 05:23 조회 6,151 댓글 1

본문

서버에 파일을 올리는데 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

참고

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

2kat님의 댓글

no_profile 2kat 아이피 (220.♡.000.000) 작성일

좋네요

전체 269건
게시물 검색

접속자집계

오늘
1,193
어제
1,445
최대
4,271
전체
292,103