一、安装配置Gogs
1.准备工作
#安装git
yum -y install git
#创建git用户
adduser git
passwd git
#切换git用户
su - git
2.官网下载二进制安装包
wget https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.zip
#解压
unzip gogs_0.11.91_linux_amd64.zip
3.修改配置
#使用root用户复制脚本文件到/etc/systemd/system
cp scripts/systemd/gogs.service /etc/systemd/system
#重新加载system文件
systemctl daemon-reload
4.启动Gogs服务
#使用root用户system启动gogs
systemctl start gogs.service
#开机自启
systemctl enable gogs.service
systemctl status gogs.service
浏览器访问对应端口,10.0.10.210:3000
二、Nginx域名转发
1.本地机Hosts清单
vim /etc/hosts
#添加一行10.0.10.210 mygogs.com
2.远程机监听转发
vim /etc/nginx/conf.d/gogs.conf
server {
listen 80;
server_name mygogs.com;
error_log /var/log/git.error.log ;
client_max_body_size 60M;
client_body_buffer_size 512k;
location / {
port_in_redirect on;
proxy_pass http://127.0.0.1:3000$request_uri;
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;
}
}
#重启Nginx服务
nginx -t
nginx -s reload
systemctl restart nginx