👉 ex05 : 로케이팅

Dockerfile 생성 

HTML 폴더 생성
🔹 Dockerfile 작성
FROM nginx COPY html /usr/share/nginx/html COPY conf/nginx.conf /etc/nginx/conf.d/default.conf ENTRYPOINT ["nginx", "-g", "daemon off;"]
전체 동작 설명
- 이미지 기반 설정: nginx이미지를 기반으로 새로운 이미지를 빌드
- 정적 파일 복사: 현재 빌드 컨텍스트의 html디렉토리 안에 있는 모든 파일을/usr/share/nginx/html디렉토리로 복사하여 Nginx가 이 파일들을 서빙
- Nginx 설정 파일 복사: 현재 빌드 컨텍스트의 conf/nginx.conf파일을 Nginx 설정 파일로 복사하여 Nginx의 동작을 설정.
- 엔트리포인트 설정: 컨테이너가 시작될 때 Nginx를 포그라운드 모드에서 실행하여 컨테이너가 종료되지 않도록 함
👉 nginx.conf 구조

location 에서 / 요청이 들어오면 root로 가서 index를 실행한다는 라우팅이 가능하다.

conf폴더 생성 
50x.html 생성
🔹 nginx.conf 전체코드
server {
    listen       80;
    server_name  localhost;
    location / {
        root   /usr/share/nginx/html;
        index  index.html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
}🔹 index.html 전체 코드
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Welcome Nginx</h1>
</body>
</html>
다시 작성해서 실행

루트 경로 
/ 로 요청했는데도, 페이지가 잘 반환되었다.
에러페이지 자동 라우팅은 잘 모르겠다. 
