Compare commits

..

No commits in common. "67a6a3660cbf3660aab8ae747586a58cbce2f32f" and "d82e8419af50c9deafe90e546e9a918d3c7426a1" have entirely different histories.

4 changed files with 18 additions and 78 deletions

View File

@ -1,23 +1,3 @@
# 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
on:
@ -33,10 +13,9 @@ jobs:
uses: actions/checkout@v4
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.NAS_SSH_KEY_ADMIN }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.NAS_SSH_KEY_ADMIN }}
- name: Deploy files via SCP
env:
@ -44,10 +23,7 @@ jobs:
PORT: ${{ secrets.NAS_PORT }}
USER: ${{ secrets.NAS_USER }}
run: |
# 기존 배포 파일 정리 및 디렉토리 준비
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 -"
- name: Apply nginx config via SSH
@ -56,21 +32,10 @@ jobs:
PORT: ${{ secrets.NAS_PORT }}
USER: ${{ secrets.NAS_USER }}
run: |
ssh -o StrictHostKeyChecking=no -o RequestTTY=no -p $PORT $USER@$HOST << 'EOF'
ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST << 'EOF'
cd ~/robeing-nginx
echo "📋 Applying nginx configuration..."
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..."
sudo /bin/cp server-nginx-default /etc/nginx/sites-available/default
sudo /usr/sbin/nginx -t
sudo /bin/systemctl reload nginx
docker compose down || true
echo "✅ Deployment completed successfully!"
EOF
EOF

View File

@ -7,9 +7,8 @@ Ubuntu 서버용 Nginx 리버스 프록시 배포 저장소입니다.
```
nginx-deploy/
├── .github/workflows/deploy.yml # GitHub Actions 배포 스크립트
├── default.conf # Docker nginx 설정 (legacy)
├── server-nginx-default # 서버 nginx 설정 파일
├── docker-compose.yml # Docker Compose 정의 (cleanup용)
├── default.conf # Nginx 설정 파일
├── docker-compose.yml # Docker Compose 정의
└── README.md # 이 파일
```
@ -19,7 +18,6 @@ nginx-deploy/
2. **GitHub Actions** 자동 실행
3. **파일 전송** (Ubuntu 서버 ~/robeing-nginx)
4. **nginx 설정 적용** (서버 nginx 자동 reload)
5. **Docker 컨테이너 정리** (기존 컨테이너 중지)
## 서버 설정
@ -40,8 +38,8 @@ NAS_SSH_KEY_ADMIN: SSH 개인키
## 프록시 라우팅
- `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)
- `https://ro-being.com/api/` → 192.168.219.45:18000 (frontend/backend)
- `https://ro-being.com/rb8001/` → 192.168.219.45:8001 (api_base)
## SSL 설정

View File

@ -1,3 +1,5 @@
version: "3.8"
services:
nginx:
image: nginx:alpine

View File

@ -130,16 +130,16 @@ server {
# API endpoints
location /api/ {
proxy_pass http://localhost:8000;
proxy_pass http://localhost:18000;
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;
}
# RB10508 API endpoints
location /rb10508/ {
proxy_pass http://localhost:10508/;
# RB8001 API endpoints
location /rb8001/ {
proxy_pass http://localhost:8001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@ -190,29 +190,4 @@ server {
return 404; # managed by Certbot
}
# 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;
}
}