Dorulog
article thumbnail
반응형

Nginx

오늘날 웹 개발의 세계에서 NGINX는 굉장히 중요한 역할을 하고 있는데요. 웹서버, 리버스 프록시, 로드 밸런서 등의 다양한 기능으로 인해 많은 기업과 개발자들이 선호하는 소프트웨어 중 하나가 되었습니다. nginx는 웹서버의 하나로 우리가 만든 서버에서 사용자에게 파일을 보여주는 역활을 합니다.

NGINX의 주요 기능

NGINX는 그 성능과 확장성으로 널리 알려져 있습니다. 이 웹서버는 동시에 수천 개의 요청을 처리할 수 있어, 대규모 트래픽을 처리하는 사이트에 매우 적합것으로 알려져 있습니다. 아파치 대비 가볍고 빠르다는 장점이 있습니다.

리버스 프록시로서의 기능

NGINX는 뛰어난 리버스 프록시로도 사용할 수 있습니다. 이 기능을 사용하면 클라이언트의 요청을 서버에 전달하고, 서버의 응답을 클라이언트에게 전송하는 역할을 수행하게 됩니다. 이를 통해  웹사이트의 보안을 강화하거나 여러 대의 서버로 부하 분산을 통해 보다 안정적인 서비스 운영을 할 수 있습니다.

로드 밸런싱

로드 밸런싱 기능을 통해, NGINX는 들어오는 트래픽을 여러 서버에 분산시켜 각 서버의 부하를 최소화할 수 있습니다. 이는 DDoS 공격 등 서버의 다운타임을 줄이고, 효율적인 리소스 활용을 가능하게 하는 장점이 있습니다.

Nginx 최신버전 설치

먼저 기본 ubuntu의 nginx 버전은 1.18버전입니다.

ubuntu@python-server:~$ nginx -v
nginx version: nginx/1.18.0 (Ubuntu)

그래서 새로운 레포지토리를 등록해야 하는데요. 순서대로 명령어를 입력해 줍니다.

sudo apt install curl gnupg2 ca-certificates lsb-release

echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list


curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

sudo apt update

sudo apt list nginx

여기 까지 진행하시면 nginx 버전이 최신버전인 1.24버전이 인식됨을 알 수 있습니다

ubuntu@python-server:~$ sudo apt list nginx
Listing... Done
nginx/stable 1.24.0-1~focal all [upgradable from: 1.18.0-0ubuntu1.4]
N: There are 9 additional versions. Please use the '-a' switch to see them.

그리고 이제 sudo apt install nginx를 하면 1.18버전이 삭제되고 1.24버전이 자동으로 설치되게 됩니다.

ubuntu@python-server:~$ sudo apt install nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libsnappy1v5 python3-cached-property python3-docker python3-dockerpty
  python3-docopt python3-texttable python3-websocket
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream nginx-common nginx-core
The following packages will be upgraded:
  nginx
1 upgraded, 0 newly installed, 6 to remove and 0 not upgraded.
Need to get 852 kB of archives.
After this operation, 1015 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://nginx.org/packages/ubuntu focal/nginx arm64 nginx arm64 1.24.0-1~focal [852 kB]
Fetched 852 kB in 3s (323 kB/s)

이후 설정을 해야하는 부분이 있는데요.

nginx의 설정파일이 기존 sites-enabled에서 conf.d/default.conf로 변경되었습니다. 해당 위치로 변경해주셔야 합니다. 그렇지 않으면 서버가 죽어있는것처럼 보이는데요. 꼭 설정 파일을 변경해주셔야 합니다.

sudo nano /etc/nginx/conf.d/default.conf

sudo nano /etc/nginx/sites-enabled/default

cp /etc/nginx/sites-enabled/default /etc/nginx/conf.d/default.conf

sudo systemctl enable nginx 
service nginx start

여기까지 진행하시면 업데이트가 완료되는데요. 최신버전의 웹서버를 사용하시는 것이 보안상 좋기 때문에 잘 설정하여 사용하시기 바랍니다. 그럼 즐거운 하루 보내세요.

728x90
profile

Dorulog

@dorudoru

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!