server{listen80;listen443ssl;ssl_certificate/etc/nginx/ssl/deimos.fr/server-unified.crt;ssl_certificate_key/etc/nginx/ssl/deimos.fr/server.key;ssl_session_timeout5m;server_namegit.deimos.fr;root/usr/share/gitweb/;access_log/var/log/nginx/git.deimos.fr_access.log;error_log/var/log/nginx/git.deimos.fr_error.log;indexgitweb.cgi;# Drop configincludedrop.conf;# Git over httpslocation/git/{alias/var/cache/git/;if($scheme=http){rewrite^https://$host$request_uripermanent;}}# Gitweblocation~gitweb\.cgi{fastcgi_cachemycache;fastcgi_cache_key$request_method$host$request_uri;fastcgi_cache_validany1h;includefastcgi_params;fastcgi_passunix:/run/fcgiwrap.socket;}}
With this configuration, Git over HTTPS is working (HTTP is redirected to HTTPS) and Gitweb is working too since everything matching gitweb.cgi is correctly routed.
Repository Configuration
For the Git part, we need to authorize the repositories we want to expose. For this, we need to rename a file in our repository and run a command: