Accès
- Ouvrez votre navigateur et rendez-vous sur :
https://<SERVER_IP> - Un avertissement SSL du navigateur est à prévoir (certificat auto-signé)
- Register a new account
- The first registered account becomes Administrator
Disable Self-Registration (Optional)
By default, user self-registration is enabled.
1. Edit the configuration file: /etc/gogs/conf/app.ini
2. Under the [auth] section, change: DISABLE_REGISTRATION = false à DISABLE_REGISTRATION = true
3. Restart Gogs:
systemctl restart gogs
Fichiers et répertoires importants
- Répertoire d'installation :
/opt/gogs - Fichier de configuration :
/etc/gogs/conf/app.ini - Application data:
/var/lib/gogs - Repositories:
/var/lib/gogs/repositories - Journaux :
/var/log/gogs - Service Systemd :
/etc/systemd/system/gogs.service - Configuration Nginx :
/etc/nginx/sites-available/gogs.conf - Certificats TLS :
/etc/nginx/ssl/
Git Usage
HTTPS (self-signed cert):
GIT_SSL_NO_VERIFY=true git clone https://<SERVER_IP>/<USERNAME>/<REPOSITORY>.git
SSH (Built-in server):
git clone ssh://git@<SERVER_IP>:2222/<USERNAME>/<REPOSITORY>.git
Gestion des services
Gogs:
systemctl status gogs
systemctl restart gogs
Nginx :
systemctl status nginx
systemctl restart nginx
PostgreSQL:
systemctl status postgresql
systemctl restart postgresql
Remarques
- The main configuration file is located at
/etc/gogs/conf/app.ini. After modifying the configuration file, restart the service usingsystemctl restart gogs. - The Nginx upload limit is defined in
/etc/nginx/sites-available/gogs.confusingclient_max_body_size. Increase it for large repositories and restart Nginx. - For large deployments, you may uncomment
LimitMEMLOCK=infinityetLimitNOFILE=65535dans/etc/systemd/system/gogs.service, then runsystemctl daemon-reloadand restart Gogs. - Database credentials are defined in
/etc/gogs/conf/app.ini. - For production use, it is recommended to replace the self-signed certificate with a valid Let’s Encrypt certificate.
- If using a self-signed certificate, HTTPS cloning requires
GIT_SSL_NO_VERIFY=true.
Activation du protocole SSL avec un domaine
1. Pointez votre domaine vers l'adresse IP du serveur.
2. Update Gogs configuration (/etc/gogs/conf/app.ini) :
EXTERNAL_URL = https://yourdomain.com/
DOMAIN = yourdomain.com
SSH_DOMAIN = yourdomain.com
3. Restart Gogs service to apply changes:
systemctl restart gogs
3. Edit Nginx config and replace both server_name <IP>; avec votre domaine (<your-domain>) pour les blocs HTTP (port 80) et HTTPS (port 443) :
vim /etc/nginx/sites-available/gogs.conf
4. Install Certbot:
apt install -y certbot python3-certbot-nginx
5. Run the following command to generate a valid Let’s Encrypt certificate:
certbot certonly --nginx --non-interactive --agree-tos --email [email protected] -d yourdomain.com
6. Replace SSL paths in Nginx config:
vim /etc/nginx/sites-available/gogs.conf
# Before:
# ssl_certificate /etc/nginx/ssl/gogs.crt;
# ssl_certificate_key /etc/nginx/ssl/gogs.key;
# After:
# ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
7. Restart Nginx to apply the changes:
systemctl restart nginx
8. Ouvrez votre navigateur et rendez-vous sur : https://yourdomain.com