nginx-infra/README.md
happybell80 66009f2326
Some checks failed
Deploy Nginx Config to Ubuntu Server / deploy (push) Has been cancelled
Add Gitea Actions workflow for nginx deployment
- Create .gitea/workflows/deploy.yml for automated nginx config deployment
- Implement local server deployment (no SSH required)
- Add automatic backup, validation, and rollback features
- Update README.md with Gitea Actions setup instructions
- Include sudo permissions configuration guide

Features:
- Automatic nginx config backup before deployment
- Configuration syntax validation
- Seamless nginx service reload
- Automatic rollback on deployment failure
- Old backup cleanup (keeps last 5)
2025-07-14 17:13:05 +09:00

79 lines
2.0 KiB
Markdown

# Nginx Deploy - Robeing Project
Ubuntu 서버용 Nginx 리버스 프록시 배포 저장소입니다.
## 구조
```
nginx-infra/
├── .gitea/workflows/deploy.yml # Gitea Actions 배포 스크립트
├── .github/workflows/deploy.yml # GitHub Actions 배포 스크립트 (legacy)
├── default.conf # Docker nginx 설정 (legacy)
├── server-nginx-default # 서버 nginx 설정 파일
├── docker-compose.yml # Docker Compose 정의 (cleanup용)
└── README.md # 이 파일
```
## 배포 플로우 (Gitea Actions)
1. **main 브랜치에 push**
2. **Gitea Actions** 자동 실행 (로컬 서버)
3. **nginx 설정 백업** (자동 백업)
4. **설정 검증** (nginx -t)
5. **nginx 설정 적용** (/etc/nginx/sites-available/default)
6. **nginx 서비스 reload** (무중단 적용)
7. **배포 검증** (자동 롤백 포함)
## 서버 설정
### Gitea Actions 요구사항
- Ubuntu 22.04 LTS
- Gitea Actions 활성화
- admin 사용자 sudo NOPASSWD 권한
- nginx 서비스 실행 중
### sudo 권한 설정
```bash
# /etc/sudoers.d/admin 파일 생성
sudo visudo -f /etc/sudoers.d/admin
# 다음 내용 추가:
admin ALL=(ALL) NOPASSWD: /usr/bin/cp, /usr/sbin/nginx, /bin/systemctl
```
## 프록시 라우팅
- `https://ro-being.com/` → 192.168.219.45:5173 (메인 프론트엔드)
- `https://ro-being.com/api/` → 192.168.219.45:8000 (frontend/backend)
- `https://ro-being.com/rb10508/` → 192.168.219.45:10508 (test_api)
## SSL 설정
서버 자체에 SSL 설정 완료:
- Ubuntu 서버에서 certbot으로 SSL 인증서 관리
- Docker 컨테이너는 8080 포트에서 HTTP만 처리
- 서버 nginx가 HTTPS → HTTP(8080) 프록시
## 로컬 테스트
```bash
# 서버에서 직접 실행
cd ~/robeing-nginx
docker compose up -d
# 로그 확인
docker compose logs -f nginx
# 내부 서비스 확인
curl http://localhost:8080
```
## 배포 상태 확인
```bash
# 서비스 상태 확인
curl -I https://ro-being.com
# 컨테이너 상태 확인
docker compose ps
```