一、安装配置Gogs

1.准备工作

  1. #安装git
  2. yum -y install git
  3. #创建git用户
  4. adduser git
  5. passwd git
  6. #切换git用户
  7. su - git

2.官网下载二进制安装包

  1. wget https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.zip
  2. #解压
  3. unzip gogs_0.11.91_linux_amd64.zip

3.修改配置

  1. #使用root用户复制脚本文件到/etc/systemd/system
  2. cp scripts/systemd/gogs.service /etc/systemd/system
  3. #重新加载system文件
  4. systemctl daemon-reload

4.启动Gogs服务

  1. #使用root用户system启动gogs
  2. systemctl start gogs.service
  3. #开机自启
  4. systemctl enable gogs.service
  5. systemctl status gogs.service

浏览器访问对应端口,10.0.10.210:3000

二、Nginx域名转发

1.本地机Hosts清单

  1. vim /etc/hosts
  2. #添加一行10.0.10.210 mygogs.com

2.远程机监听转发

  1. vim /etc/nginx/conf.d/gogs.conf
  1. server {
  2. listen 80;
  3. server_name mygogs.com;
  4. error_log /var/log/git.error.log ;
  5. client_max_body_size 60M;
  6. client_body_buffer_size 512k;
  7. location / {
  8. port_in_redirect on;
  9. proxy_pass http://127.0.0.1:3000$request_uri;
  10. proxy_redirect off;
  11. proxy_set_header Host $host;
  12. proxy_set_header X-Real-IP $remote_addr;
  13. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  14. }
  15. }
  1. #重启Nginx服务
  2. nginx -t
  3. nginx -s reload
  4. systemctl restart nginx