docker-compose.yml
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:1.14.6
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- HTTP_PORT=80
restart: always
networks:
- gitea
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:80"
- "222:22"
这将使用 默认的
SQLite3
初始化数据库
注意:
如果在 http 上使用非 3000 端口,请更改 app.ini 以匹配 LOCAL_ROOT_URL = http://localhost:3000/
gitea.moeci.com/gitea/gitea/conf/app.ini
HTTP_PORT = 80
失败:
还是无法用 https://gitea.moeci.com/
正常访问
最终配置文件
于是改回
gitea.moeci.com/gitea/gitea/conf/app.ini
HTTP_PORT = 3000
ROOT_URL = http://gitea.moeci.com:3000/
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:1.14.6
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- HTTP_PORT=3000
restart: always
networks:
- gitea
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
重新启动 docker 容器
docker-compose down
docker-compose up -d
现在,访问 http://gitea.moeci.com:3000/
就正常访问了
server {
listen 80;
listen 443 ssl http2;
server_name gitea.moeci.com;
# proxy to 3000
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;
proxy_set_header REMOTE-HOST $remote_addr;
add_header X-Cache $upstream_cache_status;
# cache
add_header Cache-Control no-cache;
expires 12h;
}
}
进入安装界面
http://gitea.moeci.com:3000/
注意: 尽管使用了 nginx,但在安装界面时,需要带上
3000
端口,不然部分前端文件会 404, 同时,这是一个http
注意:图中 基础 URL 最终失败, 请使用
http://gitea.moeci.com:3000/
代替
gitea.moeci.com/gitea/gitea/conf/app.ini
默认:
22
SSH_PORT = 222
SSH_LISTEN_PORT = 222
参考:
注意: 这里 Gitea SSH 使用了 222 端口,需要放行 222 端口
.ssh/config
# Gitea
Host gitea.moeci.com
HostName gitea.moeci.com
Port 222
User git
IdentityFile ~/.ssh/id_rsa_yiyun
测试
ssh -T git@gitea.moeci.com # Attempts to ssh to Gitea
或者
ssh -i ~/.ssh/id_rsa_yiyun -T git@gitea.moeci.com -p222
2022-3-27 17:36:06 更新, 经过测试, 完成
本地 SSH 配置
后,再关闭Cloudflare
云朵CDN, 过一会即可, 容器内部使用 22 端口, 映射到宿主机 222 端口,放行 222 端口, 本地配置gitea.moeci.com
使用 222 端口即可,之前不行,应该是没关Cloudflare CDN
注意: 不能这样指定 222 端口,无效
git clone git@gitea.moeci.com:222:yiyungent/test.git
可以下方这样指定 222 端口
git clone ssh://git@gitea.moeci.com:222/yiyungent/test.git
Gitea 容器内部使用 22 端口, 失败
git clone git@gitea.moeci.com:yiyunStarRepos/evernote-backup.git
以下为 Gitea 容器内部使用 222 端口时, 还是失败
git clone ssh://git@gitea.moeci.com:222/yiyunStarRepos/evernote-backup.git
根据官方文档, 目测还需要连通
Gitea 的镜像仓库 是一种特殊的仓库, 能够
clone
到本地, 但不可写入, 即不能再由本地push
到远程
转为 普通仓库
转为 普通仓库 后, 就可以正常
push
了
感谢帮助!
本文作者: yiyun
本文链接: https://moeci.com/posts/分类-github/gitea-notebook/
版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!