2. Servidor git https

Note

Servidor de versiones GIT sobre HTTPS

Manual para instalar y configurar un servidor NGINX para servir GIT.
El servidor git debe estar instalado y tener los permisos de ‘git:git’.

Incluir al nginx en el grupo git

1sudo chown -R git:git /home/git/<repo>
2sudo usermod -aG git nginx
3sudo chmod -R g+rx /home/git/<repo>

Confirmar los permisos del directorio

1cd /home/git
2sudo chmod g+rx /home
3sudo chmod g+rx /home/git

Habilitar el <repo> para su uso con HTTPS. Fichero /home/git/<repo>/config

1[core]
2     repositoryformatversion = 0
3     filemode = true
4     bare = true
5     sharedrepository = 1
6[receive]
7      denyNonFastforwards = true
8[http]
9      receivepack = true

Crear el fichero de validación

1touch /home/git/<repo>/git-daemon-export-ok

Protección de seguridad para repositorios compartidos

1sudo -u nginx git config --global --add safe.directory /home/git/<repo>

Socket y service para el CGI fcgiwrap

1dnf install epel-release
2dnf install fcgiwrap

Socket /etc/systemd/system/fcgiwrap-gitea.socket

1[Unit]
2Description=fcgiwrap Socket for Gitea CGI
3
4[Socket]
5ListenStream=/run/fcgiwrap/fcgiwrap-gitea.socket
6SocketMode=0666
7
8[Install]
9WantedBy=sockets.target

Service /etc/systemd/system/fcgiwrap-gitea.service

 1[Unit]
 2Description=fcgiwrap Service for Gitea CGI
 3Requires=fcgiwrap-gitea.socket
 4After=network.target
 5
 6[Service]
 7User=nginx
 8Group=nginx
 9ExecStart=/usr/sbin/fcgiwrap
10StandardInput=socket
11Restart=on-failure
12
13[Install]
14WantedBy=multi-user.target

Verificar fcgiwrap

1systemctl enable fcgiwrap-gitea.socket
2systemctl start fcgiwrap-gitea.socket
3systemctl enable fcgiwrap-gitea.service
4systemctl start fcgiwrap-gitea.service
5ls -al /run/fcgiwrap/fcgiwrap-gitea.socket

Fichero /etc/nginx/default.d/git.conf

 1location ~ (/.*) {
 2   root /home/git;
 3   include fastcgi_params;
 4   fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
 5   fastcgi_param GIT_PROJECT_ROOT /home/git;
 6   fastcgi_param PATH_INFO $uri;
 7   fastcgi_param REMOTE_USER $remote_user;
 8   fastcgi_param GIT_HTTP_EXPORT_ALL "";
 9   fastcgi_pass unix:/run/fcgiwrap/fcgiwrap-gitea.socket;
10}

Verificacion

1curl -X GET http://IP:PORT/<REPO>/info/refs?service=git-upload-pack