239 lines
6.5 KiB
Markdown
239 lines
6.5 KiB
Markdown
---
|
|
id: "gitea, qurtz 설치 20260331"
|
|
created: "2026-03-31 10:41"
|
|
tags:
|
|
---
|
|
# 🌐 개인 서버(GCP) 기반 Gitea & HTTPS 구축 가이드
|
|
|
|
본 문서는 Ubuntu 25.xx 환경에서 가벼운 Git 서비스인 **Gitea**를 설치하고, **Nginx**와 **DuckDNS**를 이용해 **HTTPS** 보안 접속을 구현한 과정을 정리합니다.
|
|
|
|
## 1. 서버 기본 환경 및 Gitea 설치
|
|
|
|
가장 가벼운 바이너리 실행 방식으로 Gitea를 설치하고 전용 사용자를 생성했습니다.
|
|
|
|
- **OS:** Ubuntu 25.xx (GCP Instance)
|
|
|
|
- **사용자 생성:** `git` 시스템 사용자 생성 (`/home/git`)
|
|
|
|
- **DB:** SQLite3 (경량화를 위해 선택)
|
|
|
|
- **바이너리 경로:** `/usr/local/bin/gitea`
|
|
|
|
- **데이터 경로:** `/var/lib/gitea`
|
|
|
|
|
|
---
|
|
|
|
## 2. 도메인 및 네트워크 설정
|
|
|
|
외부 접속을 위해 무료 DDNS 주소를 확보하고 클라우드 방화벽을 조정했습니다.
|
|
|
|
- **도메인:** `white-smith.duckdns.org` (GCP 외부 IP 연결 완료)
|
|
|
|
- **포트 개방 (GCP & UFW):**
|
|
|
|
- `22/tcp`: SSH 접속 (PuTTY, SFTP)
|
|
|
|
- `80/tcp`: HTTP (인증서 발급 및 리다이렉트용)
|
|
|
|
- `443/tcp`: HTTPS (실제 서비스용)
|
|
|
|
- **보안 조치:** 불필요한 포트(20, 21, 3389 등) 차단 및 Gitea 직접 포트(3000)는 Nginx를 거치도록 외부 차단 권장.
|
|
|
|
|
|
---
|
|
|
|
## 3. HTTPS & Nginx 리버스 프록시
|
|
|
|
Nginx를 앞단에 세워 보안을 강화하고 도메인 기반 접속을 구현했습니다.
|
|
|
|
### SSL 인증서 발급
|
|
|
|
`Certbot`을 이용해 **Let's Encrypt** 무료 SSL 인증서를 발급받았습니다.
|
|
|
|
Bash
|
|
|
|
```
|
|
sudo certbot --nginx -d white-smith.duckdns.org
|
|
```
|
|
|
|
### Nginx 최종 설정 (`/etc/nginx/sites-available/gitea`)
|
|
|
|
IP 접속 시 도메인으로 자동 전환되도록 설정했습니다.
|
|
|
|
Nginx
|
|
|
|
```
|
|
# 1. HTTP -> HTTPS 리다이렉트 (IP 포함)
|
|
server {
|
|
listen 80;
|
|
server_name 34.19.79.94 white-smith.duckdns.org;
|
|
return 301 https://white-smith.duckdns.org$request_uri;
|
|
}
|
|
|
|
# 2. HTTPS 서비스 블록
|
|
server {
|
|
listen 443 ssl;
|
|
server_name white-smith.duckdns.org;
|
|
|
|
# SSL 인증서 경로 (Certbot 관리)
|
|
ssl_certificate /etc/letsencrypt/live/white-smith.duckdns.org/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/white-smith.duckdns.org/privkey.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;
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 4. Gitea 내부 설정 업데이트
|
|
|
|
HTTPS 환경에 맞춰 `/etc/gitea/app.ini` 파일을 `vi`로 수정했습니다.
|
|
|
|
- **ROOT_URL:** `https://white-smith.duckdns.org/`
|
|
|
|
- **DOMAIN:** `white-smith.duckdns.org`
|
|
|
|
- **SSH_DOMAIN:** `white-smith.duckdns.org`
|
|
|
|
|
|
---
|
|
|
|
## 5. 현재 상태 요약
|
|
|
|
1. **HTTPS 접속:** `https://white-smith.duckdns.org`로 안전하게 접속 가능.
|
|
|
|
2. **IP 리다이렉트:** `34.19.79.94` 입력 시 자동으로 도메인 주소로 전환됨.
|
|
|
|
3. **파일 전송:** 포트 22번을 통해 SFTP 방식으로 안전하게 파일 관리 중.
|
|
|
|
|
|
|
|
# 🚀 Gitea & Quartz 도메인 통합 및 서버 설정 가이드
|
|
|
|
본 가이드는 단일 메인 도메인(`white-smith.duckdns.org`)에서 **Quartz(블로그)**와 **Gitea(Git 서비스)**를 충돌 없이 운영하기 위한 설정법을 다룹니다.
|
|
|
|
---
|
|
|
|
## 1. 서비스 주소 설계
|
|
|
|
동일 도메인 점유 문제를 해결하기 위해 **하위 경로(Path)** 방식으로 서비스를 분리했습니다.
|
|
|
|
- **Quartz (메인 블로그):** `https://white-smith.duckdns.org/`
|
|
|
|
- **Gitea (코드 저장소):** `https://white-smith.duckdns.org/git/`
|
|
|
|
|
|
---
|
|
|
|
## 2. Gitea 설정 수정 (`app.ini`)
|
|
|
|
Gitea가 `/git/` 경로를 인식하도록 내부 설정을 변경해야 합니다.
|
|
|
|
- **파일 위치:** `/var/lib/gitea/custom/conf/app.ini` (또는 설치 경로 내 `custom/conf/app.ini`)
|
|
|
|
- **수정 내용:**
|
|
|
|
Ini, TOML
|
|
|
|
```
|
|
[server]
|
|
ROOT_URL = https://white-smith.duckdns.org/git/
|
|
LOCAL_ROOT_URL = http://127.0.0.1:3000/
|
|
HTTP_ADDR = 127.0.0.1
|
|
HTTP_PORT = 3000
|
|
```
|
|
|
|
> **Tip:** `LOCAL_ROOT_URL`을 추가해야 내부 리다이렉션 시 404 오류를 방지할 수 있습니다.
|
|
|
|
|
|
---
|
|
|
|
## 3. Nginx 역방향 프록시 설정
|
|
|
|
`/etc/nginx/sites-available/gitea` 파일을 수정하여 두 서비스를 통합합니다.
|
|
|
|
Nginx
|
|
|
|
```
|
|
server {
|
|
listen 80;
|
|
server_name 34.19.79.94 white-smith.duckdns.org;
|
|
return 301 https://white-smith.duckdns.org$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
server_name white-smith.duckdns.org;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/white-smith.duckdns.org/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/white-smith.duckdns.org/privkey.pem;
|
|
|
|
# [우선순위 1] Gitea 설정
|
|
location /git/ {
|
|
proxy_pass http://127.0.0.1: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;
|
|
}
|
|
|
|
# [우선순위 2] Quartz 설정 (메인)
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8080; # Quartz 실행 포트
|
|
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;
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 4. 권한 관리 및 접근 (etc 경로)
|
|
|
|
시스템 설정 파일을 편리하게 수정하기 위해 권한을 조정하거나 도구를 활용합니다.
|
|
|
|
1. **권한 변경 (추천):**
|
|
|
|
Bash
|
|
|
|
```
|
|
sudo chown -R root:$(whoami) /etc/nginx
|
|
sudo chmod -R 775 /etc/nginx
|
|
```
|
|
|
|
2. **포트 확인 명령어:**
|
|
|
|
Bash
|
|
|
|
```
|
|
sudo ss -tulpn | grep node # Quartz 포트 확인
|
|
```
|
|
|
|
3. **서비스 재시작:**
|
|
|
|
Bash
|
|
|
|
```
|
|
sudo nginx -t && sudo systemctl restart nginx
|
|
sudo systemctl restart gitea
|
|
```
|
|
|
|
|
|
---
|
|
|
|
## 5. 핵심 주의사항
|
|
|
|
- **Nginx 경로 슬래시:** `proxy_pass http://127.0.0.1:3000/;` 처럼 끝에 `/`가 있어야 `/git/` 경로가 중복되지 않고 올바르게 전달됩니다.
|
|
|
|
- **Quartz 실행:** Quartz를 `npx quartz build --serve`로 띄운 경우 해당 포트(보통 8080)가 Nginx 설정과 일치해야 합니다.
|
|
|
|
- **보안:** `/etc` 전체 권한을 `777`로 바꾸지 마세요. 필요한 폴더만 그룹 권한을 부여하는 것이 안전합니다. |