# Gogs 配置 HTTPS
Gogs 一款极易搭建的自助 Git 服务
官方网站 https://gogs.io (opens new window)
配置文件手册 https://gogs.io/docs/advanced/configuration_cheat_sheet (opens new window)
提示
假设已经搭建完 Gogs
编辑 Gogs 配置文件
vi gogs/custom/conf/app.ini
把 ROOT_URL 的 http 改成 https
保存退出
注意
其他地方请不要动!
[server]
DOMAIN = git.ilouis.cn
HTTP_PORT = 3000
ROOT_URL = https://git.ilouis.cn/
DISABLE_SSH = true
OFFLINE_MODE = false
在 nginx 中新建一个虚拟主机配置,示例如下
server
{
listen 80;
server_name git.ilouis.cn; # 域名
return 301 https://$server_name$request_uri;
}
server
{
listen 443 ssl http2;
server_name git.ilouis.cn; # 域名
ssl_certificate /etc/ssl/git.crt; # 证书位置
ssl_certificate_key /etc/ssl/git.key; # 证书key位置
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
charset utf-8;
location / {
client_max_body_size 50M; # 附件上传大小
proxy_pass http://127.0.0.1:3000; # Gogs
proxy_redirect off;
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_http_version 1.1;
}
}
重启 Nginx
systemctl restart nginx