148 lines
3.9 KiB
Markdown
148 lines
3.9 KiB
Markdown
# Wiki.js 和 Gitea 部署记录(2026-08-05)
|
||
|
||
## 架构
|
||
|
||
```
|
||
https://suyushi.top → LobeHub (Nginx → :3210)
|
||
https://wiki.suyushi.top → Wiki.js (Nginx → :3000)
|
||
https://git.suyushi.top → Gitea (Nginx → :3001)
|
||
```
|
||
|
||
三服务共用同一个 Postgres 实例(lobe-postgres 容器),各自独立数据库。
|
||
|
||
---
|
||
|
||
## Wiki.js 部署
|
||
|
||
### 容器参数
|
||
```bash
|
||
docker run -d \
|
||
--name wikijs \
|
||
--network lobehub_lobe-network \
|
||
--restart unless-stopped \
|
||
-p 3000:3000 \
|
||
-e DB_TYPE=postgres \
|
||
-e DB_HOST=postgresql \
|
||
-e DB_PORT=5432 \
|
||
-e DB_USER=postgres \
|
||
-e DB_PASS="$DB_PASS" \
|
||
-e DB_NAME=wiki \
|
||
ghcr.io/requarks/wiki:2
|
||
```
|
||
|
||
### 数据库
|
||
- 实例:现有 lobe-postgres 容器
|
||
- 数据库名:`wiki`
|
||
- 创建命令:`docker compose -f /lobehub/docker-compose.yml exec -T postgresql psql -U postgres -c 'CREATE DATABASE wiki;'`
|
||
|
||
### Nginx 配置
|
||
```nginx
|
||
server {
|
||
listen 80;
|
||
server_name wiki.suyushi.top;
|
||
location / {
|
||
proxy_pass http://127.0.0.1:3000;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection "upgrade";
|
||
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;
|
||
}
|
||
}
|
||
```
|
||
|
||
### DNS
|
||
- 类型:A 记录
|
||
- 主机:`wiki`
|
||
- 值:`8.210.128.95`
|
||
|
||
### SSL
|
||
```bash
|
||
certbot --nginx -d wiki.suyushi.top --non-interactive --agree-tos --email panghusys2025@gmail.com --redirect
|
||
```
|
||
|
||
---
|
||
|
||
## Gitea 部署
|
||
|
||
### 容器参数
|
||
```bash
|
||
docker run -d \
|
||
--name gitea \
|
||
--network lobehub_lobe-network \
|
||
--restart unless-stopped \
|
||
-p 3001:3000 -p 2222:22 \
|
||
-e GITEA__database__DB_TYPE=postgres \
|
||
-e GITEA__database__HOST=postgresql:5432 \
|
||
-e GITEA__database__NAME=gitea \
|
||
-e GITEA__database__USER=postgres \
|
||
-e GITEA__database__PASSWD="$DB_PASS" \
|
||
-e GITEA__server__DOMAIN=git.suyushi.top \
|
||
-e GITEA__server__ROOT_URL=https://git.suyushi.top \
|
||
-e GITEA__server__SSH_DOMAIN=git.suyushi.top \
|
||
-e GITEA__server__SSH_PORT=2222 \
|
||
-e GITEA__server__REVERSE_PROXY_TRUSTED_PROXIES=127.0.0.1 \
|
||
-e GITEA__service__DISABLE_REGISTRATION=true \
|
||
-v /lobehub/gitea:/data \
|
||
gitea/gitea:latest
|
||
```
|
||
|
||
### 数据库
|
||
- 实例:现有 lobe-postgres 容器
|
||
- 数据库名:`gitea`
|
||
- 创建命令:`docker compose -f /lobehub/docker-compose.yml exec -T postgresql psql -U postgres -c 'CREATE DATABASE gitea;'`
|
||
|
||
### Nginx 配置
|
||
```nginx
|
||
server {
|
||
listen 80;
|
||
server_name git.suyushi.top;
|
||
client_max_body_size 100M;
|
||
location / {
|
||
proxy_pass http://127.0.0.1:3001;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection "upgrade";
|
||
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;
|
||
}
|
||
}
|
||
```
|
||
|
||
### DNS
|
||
- 类型:A 记录
|
||
- 主机:`git`
|
||
- 值:`8.210.128.95`
|
||
|
||
### SSL
|
||
```bash
|
||
certbot --nginx -d git.suyushi.top --non-interactive --agree-tos --email panghusys2025@gmail.com --redirect
|
||
```
|
||
|
||
### 管理员设置
|
||
```bash
|
||
# 注册账号后通过 CLI 查看用户
|
||
docker exec -u git gitea gitea admin user list
|
||
|
||
# 管理员:suyushi
|
||
```
|
||
|
||
### SSH Clone 地址格式
|
||
```bash
|
||
git clone ssh://git@git.suyushi.top:2222/用户名/仓库名.git
|
||
```
|
||
|
||
## 注意事项
|
||
|
||
| 项目 | 注意 |
|
||
|------|------|
|
||
| 容器网络 | 三服务都在 `lobehub_lobe-network` 上,通过容器名互相访问 |
|
||
| Nginx 配置路径 | `/etc/nginx/conf.d/` 下各自独立 conf 文件 |
|
||
| 端口映射 | 3000(Wiki.js)、3001(Gitea)、3210(LobeHub) — 只对内,Nginx 对外 |
|
||
| DNS 新增子域名 | Namesilo API 调不通时从服务器端 `curl` 调用 |
|
||
| DNS A 记录 vs CNAME | Let's Encrypt 验证需要 A 记录,子域名不用 CNAME |
|