JSCODE Logo
프로그래밍 과외블로그후기멘토진
회사명 : JSCODE대표 : 박재성사업자 등록번호 : 244-22-01557통신판매업 : 제 2023-인천미추홀-0381 호
학원 명칭 : 제이에스코드(JSCODE)원격학원학원설립ㆍ운영 등록번호 : 제6063호

서울특별시 구로구 경인로 20가길 11(오류동, 아델리아)

Copyright ⓒ 2025 JSCODE - 최상위 현업 개발자들의 프로그래밍 교육 All rights reserved.

이용약관개인정보처리방침
← 블로그 목록으로 돌아가기

[실습] Nginx 기본 문법 응용해보기 - 1

JSCODE 박재성
JSCODE 박재성
2025-12-06
author
JSCODE 박재성
category
Nginx
createdAt
Dec 6, 2025
series
비전공자도 이해할 수 있는 Nginx 입문/실전
slug
nginx-config-practice-1
type
post
updatedAt
Dec 6, 2025 04:47 AM
👨🏻‍🏫
기본 문법을 해석하고 정리했다면 하나씩 바꿔가면서 응용해봐야 한다. 이렇게도 가지고 놀아보고, 저렇게도 가지고 놀아봐야 한다. 그러면서 코드를 하나씩 수정하면서 의도한대로 작동하는 지 눈으로 확인하는 작업을 반드시 거쳐야 한다. 이렇게 학습하면 정말 빠르게 배울 수 있다.
 

✅ Nginx 기본 웹 사이트 수정해보기

  1. 설정 파일 확인하기
    1. $ cd /etc/nginx/conf.d/default.conf
       
      /etc/nginx/conf.d/default.conf
      server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } # / 으로 시작하는 모든 경로를 처리 (ex. /index.html) location / { # /jscode.html로 요청이 들어오면 /usr/share/nginx/html/jscode.html 파일로 응답 root /usr/share/nginx/html; # /로 요청이 들어오면 /usr/share/nginx/html/index.html로 응답 # 만약 /usr/share/nginx/html/index.html이 없을 경우, /usr/share/nginx/html/index.htm으로 응답 index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
       
  1. 기존 웹 페이지 접속해보기
    1. http://{EC2 IP 주소}로 접속해보자.
      notion image
       
  1. 기본 웹 페이지 수정하기
    1. $ cd /usr/share/nginx/html $ sudo vi index.html
       
      /usr/share/nginx/html/index.html
      <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to JSCODE!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
       
  1. 웹 페이지가 수정됐는 지 확인하기
    1. http://{EC2 IP 주소}로 접속해보자.
      notion image
 
 

✅ Nginx 에러 페이지 수정해보기

  1. 설정 파일 확인하기
    1. $ cd /etc/nginx/conf.d/default.conf
       
      /etc/nginx/conf.d/default.conf
      server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; # /50x.html과 완전히 일치하는 경로를 처리 location = /50x.html { # /50x.html로 요청이 들어오면 /usr/share/nginx/html/50x.html 파일로 응답 root /usr/share/nginx/html; } }
       
  1. 기존 에러 페이지 접속해보기
    1. notion image
       
  1. 기본 에러 페이지 수정하기
    1. $ cd /usr/share/nginx/html $ sudo vi 50x.html
       
      /usr/share/nginx/html/50x.html
      <!DOCTYPE html> <html> <head> <title>Error</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Error!</h1> <p>Sorry, the page you are looking for is currently unavailable.<br/> Please try again later.</p> <p>If you are the system administrator of this resource then you should check the error log for details.</p> <p><em>Faithfully yours, nginx.</em></p> </body> </html>
       
  1. 에러 페이지가 수정됐는 지 확인하기
    1. http://{EC2 IP 주소}/50x.html로 접속해보자.
      notion image
 
 
 
 
author
JSCODE 박재성
category
Nginx
createdAt
Dec 6, 2025
series
비전공자도 이해할 수 있는 Nginx 입문/실전
slug
type
series-footer
updatedAt
Dec 6, 2025 05:04 AM
📎
이 글은 비전공자도 이해할 수 있는 Nginx 입문/실전 강의의 수업 자료 중 일부입니다.