(1,'95593fea-f1c9-4419-8129-4f7042f6d6b7',0,'담배는 몸에 해울까요?','[{"a":"해롭습니다.","c":"1"},{"a":"해롭지 않아요.","c":"0"},{"a":"건강에 도움을 줍니다.","c":"0"}]','Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.',1,1,'2024-08-07 13:45:00',NULL),
(2,'7b33cba4-5d67-4b2d-a0a3-967b52010e31',0,'간접흡연은 건강에 어떤 영향을 미칠까요?','[{"a":"건강에 도움이 된다.","c":"0"},{"a":"폐와 심장에 이상이 생길 수 있다.","c":"1"},{"a":"면역력을 강화시킨다.","c":"0"}]','Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum The Extremes of Good and Evil by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line in section 1.10.32.',1,1,'2024-08-07 13:51:27',NULL),
(3,'b7b0f753-2d10-4a1d-8520-49339c876355',0,'길바닥에 버려진 담배를 주워 버릴때는 어떻게 해야 할까요?','[{"a":"담배를 주워서 다시 피운다.","c":"0"},{"a":"담배를 주워서 친구에게 던진다.","c":"0"},{"a":"장갑을 끼고 담배를 주워서 분리수거한다.","c":"1"}]','The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.',1,1,'2024-08-07 13:51:27',NULL),
(4,'7afebcd4-2358-4eb2-8c42-e4ac51696e25',0,'미션 5 문제 추가 테스트','[{"a":"ㄹ","c":"0"},{"a":"ㅇ","c":"0"},{"a":"ㄴ","c":"1"}]','ㄹㅇㄴㅁㄹㅇㄴㅁ ㄹㅇㄴㅁㄹㅇㄴㅁ ㄹㅇㄴㅁ ㄹㅇㄴㅁ.',5,1,'2024-08-22 16:09:40',NULL),
(16,'2536796d-3372-4075-9948-de2bd62fff47',0,'무씨에 담뱃물을 주니 어떤 결과가 벌어졌나요?','[{"a":"죽음","c":"1"},{"a":"모름","c":"0"},{"a":"건강","c":"0"}]','해설',8,1,'2024-09-11 12:38:25',NULL);
본 프로젝트는 Docker를 사용하여 Nginx 기반의 리버스 프록시 서버를 구축하고, Let's Encrypt의 `certbot`을 통해 SSL/TLS 인증서를 발급 및 관리하는 환경을 제공합니다. 여러 웹 애플리케이션의 트래픽을 단일 진입점에서 처리하고, 안전한 HTTPS 통신을 적용하는 데 사용됩니다.
## 기술 아키텍처
시스템은 모든 기능이 포함된 단일 Docker 컨테이너로 구성되어 있으며, 모든 중요 설정과 데이터는 호스트 머신에 볼륨으로 마운트하여 관리하는 Stateless 아키텍처를 따릅니다.
-**`Dockerfile`**: `ubuntu:20.04` 베이스 이미지 위에 다음의 핵심 소프트웨어를 설치합니다.
-`nginx`: 메인 리버스 프록시 서버.
-`openssh-server`: 원격 관리를 위한 SSH 서버.
-`certbot` & `python3-certbot-nginx`: Let's Encrypt의 공식 클라이언트와 Nginx 설정을 자동으로 수정해주는 Certbot 플러그인.
-**`docker-compose.yml`**:
-**단일 서비스 `os`**: `Dockerfile`을 빌드하여 `nginx_proxy`라는 이름의 컨테이너를 생성합니다.
-**포트 매핑**: 웹 트래픽의 표준 포트인 `80`(HTTP), `443`(HTTPS)과 원격 관리를 위한 `22`(SSH) 포트를 호스트와 직접 연결합니다.
-**볼륨 마운트 (핵심)**:
-`./nginx.conf`: Nginx의 메인 설정 파일.
-`./sites-available`, `./sites-enabled`: 가상 호스트(Server Block) 설정 디렉토리.
-`./letsencrypt`: `certbot`이 생성하는 계정 정보, 인증서, 갱신 설정 등 모든 데이터.
-`./ssl`, `./ssl-certs`: Nginx가 사용할 SSL 인증서 파일.
- 이 구조를 통해 컨테이너는 상태 없이(stateless) 실행 환경만 제공하며, 모든 설정과 데이터는 호스트에서 영속적으로 관리됩니다.
-**`start_service.sh`**: 컨테이너 시작 시 SSH 서버와 Nginx를 백그라운드로 실행하고, 컨테이너가 종료되지 않도록 대기하는 단순한 구조입니다.
## 주요 기능 및 운영 방식
-**리버스 프록시**: HTTP/HTTPS 요청을 수신하여, `sites-available`에 설정된 도메인 규칙에 따라 내부망의 다른 웹 애플리케이션으로 요청을 전달(Proxy Pass)합니다.
-**SSL 인증서 발급**: `certbot` CLI를 사용하여 Let's Encrypt로부터 SSL 인증서를 발급받습니다. `python3-certbot-nginx` 플러그인을 통해 Nginx 설정을 자동으로 수정하여 HTTPS를 적용할 수 있습니다.
```bash
# 컨테이너 접속
docker exec-it nginx_proxy /bin/bash
# Certbot 실행 (예시)
certbot --nginx-d example.com -d www.example.com
```
-**SSL 인증서 갱신**:
-**주의**: 현재 설정에는 **인증서 자동 갱신 로직이 포함되어 있지 않습니다.**
- Let's Encrypt 인증서는 90일마다 만료되므로, 관리자가 주기적으로 컨테이너에 접속하여 아래 명령어를 실행하거나, 호스트 시스템에 별도의 cron 작업을 설정하여 자동화를 구성해야 합니다.
```bash
# 건식 실행 (실제 갱신 없이 테스트)
certbot renew --dry-run
# 실제 갱신
certbot renew
```
## 실행 방법
### 사전 요구사항
- Docker 및 Docker Compose
- 프록시할 도메인 및 해당 도메인이 서버의 공인 IP를 가리키도록 설정된 DNS 레코드.
### 실행
1.**초기 설정**:
-`sites-available` 디렉토리에 프록시할 서버 블록 파일을 생성합니다. (최초 인증서 발급을 위해 80번 포트에 대한 서버 블록이 필요합니다.)
2.**컨테이너 실행**:
```bash
# (선택) 재빌드 및 실행 스크립트
./rebuild_docker.sh
# 또는 docker-compose 직접 실행
docker-compose up --build-d
```
3.**인증서 발급 및 적용**:
- 위의 "주요 기능 및 운영 방식" 섹션을 참고하여 컨테이너에 접속한 뒤 `certbot` 명령어를 실행합니다.