Compare commits
10 Commits
d82e8419af
...
67a6a3660c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67a6a3660c | ||
|
|
f5ab712ea4 | ||
|
|
42ec74c348 | ||
|
|
0f18ab56d1 | ||
|
|
2bdf37ca7e | ||
|
|
45efd03a93 | ||
|
|
6ba7e1bf0f | ||
|
|
c9c3d1f3dd | ||
|
|
985b997199 | ||
|
|
9aa89081ed |
49
.github/workflows/deploy.yml
vendored
49
.github/workflows/deploy.yml
vendored
@ -1,3 +1,23 @@
|
|||||||
|
# Ubuntu 서버 nginx 설정 자동 배포 워크플로우
|
||||||
|
#
|
||||||
|
# 성공 조건:
|
||||||
|
# - Ubuntu 서버 SSH 접속 가능
|
||||||
|
# - admin 사용자 sudo NOPASSWD 설정 완료
|
||||||
|
# - nginx 서비스 실행 중
|
||||||
|
#
|
||||||
|
# 실패 조건:
|
||||||
|
# - SSH 키 인증 실패
|
||||||
|
# - sudo 권한 없음
|
||||||
|
# - nginx 설정 문법 오류
|
||||||
|
# - 시스템 서비스 오류
|
||||||
|
#
|
||||||
|
# 주요 작업:
|
||||||
|
# 1. SSH 키 설정
|
||||||
|
# 2. 소스 파일 전송 (~/robeing-nginx)
|
||||||
|
# 3. nginx 설정 적용 (/etc/nginx/sites-available/default)
|
||||||
|
# 4. nginx 서비스 reload
|
||||||
|
# 5. Docker 컨테이너 정리
|
||||||
|
|
||||||
name: Deploy to Ubuntu Server
|
name: Deploy to Ubuntu Server
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@ -13,9 +33,10 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup SSH key
|
- name: Setup SSH key
|
||||||
uses: webfactory/ssh-agent@v0.9.0
|
run: |
|
||||||
with:
|
mkdir -p ~/.ssh
|
||||||
ssh-private-key: ${{ secrets.NAS_SSH_KEY_ADMIN }}
|
echo "${{ secrets.NAS_SSH_KEY_ADMIN }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
|
||||||
- name: Deploy files via SCP
|
- name: Deploy files via SCP
|
||||||
env:
|
env:
|
||||||
@ -23,7 +44,10 @@ jobs:
|
|||||||
PORT: ${{ secrets.NAS_PORT }}
|
PORT: ${{ secrets.NAS_PORT }}
|
||||||
USER: ${{ secrets.NAS_USER }}
|
USER: ${{ secrets.NAS_USER }}
|
||||||
run: |
|
run: |
|
||||||
|
# 기존 배포 파일 정리 및 디렉토리 준비
|
||||||
ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST "rm -rf ~/robeing-nginx/* || true; mkdir -p ~/robeing-nginx"
|
ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST "rm -rf ~/robeing-nginx/* || true; mkdir -p ~/robeing-nginx"
|
||||||
|
|
||||||
|
# 소스 파일 전송 (.git 제외)
|
||||||
tar --exclude='.git' -czf - . | ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST "cd ~/robeing-nginx && tar -xzf -"
|
tar --exclude='.git' -czf - . | ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST "cd ~/robeing-nginx && tar -xzf -"
|
||||||
|
|
||||||
- name: Apply nginx config via SSH
|
- name: Apply nginx config via SSH
|
||||||
@ -32,10 +56,21 @@ jobs:
|
|||||||
PORT: ${{ secrets.NAS_PORT }}
|
PORT: ${{ secrets.NAS_PORT }}
|
||||||
USER: ${{ secrets.NAS_USER }}
|
USER: ${{ secrets.NAS_USER }}
|
||||||
run: |
|
run: |
|
||||||
ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST << 'EOF'
|
ssh -o StrictHostKeyChecking=no -o RequestTTY=no -p $PORT $USER@$HOST << 'EOF'
|
||||||
cd ~/robeing-nginx
|
cd ~/robeing-nginx
|
||||||
sudo /bin/cp server-nginx-default /etc/nginx/sites-available/default
|
|
||||||
sudo /usr/sbin/nginx -t
|
echo "📋 Applying nginx configuration..."
|
||||||
sudo /bin/systemctl reload nginx
|
sudo -n /usr/bin/cp server-nginx-default /etc/nginx/sites-available/default
|
||||||
|
|
||||||
|
echo "🔍 Testing nginx configuration..."
|
||||||
|
sudo -n /usr/sbin/nginx -t
|
||||||
|
|
||||||
|
echo "🔄 Reloading nginx service..."
|
||||||
|
sudo -n /bin/systemctl reload nginx
|
||||||
|
|
||||||
|
echo "🧹 Cleaning up Docker containers..."
|
||||||
docker compose down || true
|
docker compose down || true
|
||||||
|
|
||||||
|
echo "✅ Deployment completed successfully!"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
10
README.md
10
README.md
@ -7,8 +7,9 @@ Ubuntu 서버용 Nginx 리버스 프록시 배포 저장소입니다.
|
|||||||
```
|
```
|
||||||
nginx-deploy/
|
nginx-deploy/
|
||||||
├── .github/workflows/deploy.yml # GitHub Actions 배포 스크립트
|
├── .github/workflows/deploy.yml # GitHub Actions 배포 스크립트
|
||||||
├── default.conf # Nginx 설정 파일
|
├── default.conf # Docker nginx 설정 (legacy)
|
||||||
├── docker-compose.yml # Docker Compose 정의
|
├── server-nginx-default # 서버 nginx 설정 파일
|
||||||
|
├── docker-compose.yml # Docker Compose 정의 (cleanup용)
|
||||||
└── README.md # 이 파일
|
└── README.md # 이 파일
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ nginx-deploy/
|
|||||||
2. **GitHub Actions** 자동 실행
|
2. **GitHub Actions** 자동 실행
|
||||||
3. **파일 전송** (Ubuntu 서버 ~/robeing-nginx)
|
3. **파일 전송** (Ubuntu 서버 ~/robeing-nginx)
|
||||||
4. **nginx 설정 적용** (서버 nginx 자동 reload)
|
4. **nginx 설정 적용** (서버 nginx 자동 reload)
|
||||||
|
5. **Docker 컨테이너 정리** (기존 컨테이너 중지)
|
||||||
|
|
||||||
## 서버 설정
|
## 서버 설정
|
||||||
|
|
||||||
@ -38,8 +40,8 @@ NAS_SSH_KEY_ADMIN: SSH 개인키
|
|||||||
## 프록시 라우팅
|
## 프록시 라우팅
|
||||||
|
|
||||||
- `https://ro-being.com/` → 192.168.219.45:5173 (메인 프론트엔드)
|
- `https://ro-being.com/` → 192.168.219.45:5173 (메인 프론트엔드)
|
||||||
- `https://ro-being.com/api/` → 192.168.219.45:18000 (frontend/backend)
|
- `https://ro-being.com/api/` → 192.168.219.45:8000 (frontend/backend)
|
||||||
- `https://ro-being.com/rb8001/` → 192.168.219.45:8001 (api_base)
|
- `https://ro-being.com/rb10508/` → 192.168.219.45:10508 (test_api)
|
||||||
|
|
||||||
## SSL 설정
|
## SSL 설정
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
version: "3.8"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
|
|||||||
@ -130,16 +130,16 @@ server {
|
|||||||
|
|
||||||
# API endpoints
|
# API endpoints
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://localhost:18000;
|
proxy_pass http://localhost:8000;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
# RB8001 API endpoints
|
# RB10508 API endpoints
|
||||||
location /rb8001/ {
|
location /rb10508/ {
|
||||||
proxy_pass http://localhost:8001;
|
proxy_pass http://localhost:10508/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
@ -191,3 +191,28 @@ server {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Gitea server configuration
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name git.ro-being.com;
|
||||||
|
return 301 https://$server_name$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
server_name git.ro-being.com;
|
||||||
|
|
||||||
|
ssl_certificate /etc/letsencrypt/live/ro-being.com/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/ro-being.com/privkey.pem;
|
||||||
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||||
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:3000/;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user