summaryrefslogtreecommitdiffstats
path: root/roles/git/files
diff options
context:
space:
mode:
Diffstat (limited to 'roles/git/files')
-rw-r--r--roles/git/files/etc/nginx/sites-available/git54
-rw-r--r--roles/git/files/etc/systemd/system/cgit.service23
-rw-r--r--roles/git/files/etc/systemd/system/cgit.socket11
-rw-r--r--roles/git/files/etc/systemd/system/git-http-backend.service21
-rw-r--r--roles/git/files/etc/systemd/system/git-http-backend.socket11
-rw-r--r--roles/git/files/etc/uwsgi/apps-available/cgit.ini6
-rw-r--r--roles/git/files/etc/uwsgi/apps-available/git-http-backend.ini8
7 files changed, 98 insertions, 36 deletions
diff --git a/roles/git/files/etc/nginx/sites-available/git b/roles/git/files/etc/nginx/sites-available/git
index 73ac1e6..9e9d16e 100644
--- a/roles/git/files/etc/nginx/sites-available/git
+++ b/roles/git/files/etc/nginx/sites-available/git
@@ -4,7 +4,7 @@ server {
server_name git.fripost.org;
- include snippets/acme-challenge.conf;
+ include /etc/lacme/nginx.conf;
access_log /var/log/nginx/git.access.log;
error_log /var/log/nginx/git.error.log info;
@@ -25,44 +25,54 @@ server {
error_log /var/log/nginx/git.error.log info;
include snippets/headers.conf;
+ add_header Content-Security-Policy
+ "default-src 'none'; img-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self'; frame-ancestors 'none'; form-action 'self'";
include snippets/ssl.conf;
ssl_certificate ssl/git.fripost.org.pem;
ssl_certificate_key ssl/git.fripost.org.key;
include snippets/git.fripost.org.hpkp-hdr;
- location ^~ /static/ {
- alias /usr/share/cgit/;
- expires 30d;
- }
+ gzip on;
+ gzip_vary on;
+ gzip_min_length 256;
+ gzip_types application/javascript application/json application/xml image/svg+xml image/x-icon text/css text/plain;
- # Bypass the CGI to return static files stored on disk. Try first repo with
- # a trailing '.git', then without.
- location ~* "^/((?U)[^/]+)(?:\.git)?/objects/(?:[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(?:pack|idx))$" {
- root /var/lib/gitolite/repositories;
- try_files /$1.git/objects/$2 /$1/objects/$2 =404;
+ location ^~ /static/ {
expires 30d;
- gzip off;
- # TODO honor git-daemon-export-ok
+ alias /usr/share/cgit/;
}
# disallow push over HTTP/HTTPS
- location ~* "^/[^/]+/git-receive-pack$" { return 403; }
+ location ~ "^/.+/git-receive-pack$" { return 403; }
- location ~* "^/[^/]+/(?:HEAD|info/refs|objects/info/[^/]+|git-upload-pack)$" {
+ location ~ "^/.+/(?:info/refs|git-upload-pack)$" {
+ limit_except GET POST { deny all; }
+ fastcgi_buffering off;
gzip off;
- include uwsgi_params;
- uwsgi_modifier1 9;
- uwsgi_param GIT_PROJECT_ROOT /var/lib/gitolite/repositories;
- uwsgi_pass unix:/run/uwsgi/app/git-http-backend/socket;
+
+ fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
+ fastcgi_param NO_BUFFERING "";
+
+ # cf. git-http-backend(1)
+ fastcgi_param GIT_PROJECT_ROOT /var/lib/gitolite/repositories;
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_param CONTENT_TYPE $content_type;
+ fastcgi_param QUERY_STRING $query_string;
+ fastcgi_param REQUEST_METHOD $request_method;
+ fastcgi_pass unix:/run/git-http-backend.socket;
}
+ location = /robots.txt { root /usr/share/cgit; }
+ location = /favicon.ico { root /usr/share/cgit; }
# send all other URLs to cgit
location / {
- gzip off;
- include uwsgi_params;
- uwsgi_modifier1 9;
- uwsgi_pass unix:/run/uwsgi/app/cgit/socket;
+ fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_param CONTENT_TYPE $content_type;
+ fastcgi_param QUERY_STRING $query_string;
+ fastcgi_param REQUEST_METHOD $request_method;
+ fastcgi_pass unix:/run/cgit.socket;
}
}
diff --git a/roles/git/files/etc/systemd/system/cgit.service b/roles/git/files/etc/systemd/system/cgit.service
new file mode 100644
index 0000000..08037ac
--- /dev/null
+++ b/roles/git/files/etc/systemd/system/cgit.service
@@ -0,0 +1,23 @@
+[Unit]
+Description=hyperfast web frontend for git repositories written in C
+Documentation=https://git.zx2c4.com/cgit/
+
+[Service]
+User=_cgit
+Group=nogroup
+SupplementaryGroups=gitolite
+ExecStart=/usr/sbin/fcgiwrap
+SyslogIdentifier=cgit
+#
+# Hardening
+NoNewPrivileges=yes
+PrivateDevices=yes
+ProtectHome=yes
+ProtectSystem=strict
+ProtectControlGroups=yes
+ProtectKernelModules=yes
+ProtectKernelTunables=yes
+ReadWriteDirectories=/var/cache/cgit
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/git/files/etc/systemd/system/cgit.socket b/roles/git/files/etc/systemd/system/cgit.socket
new file mode 100644
index 0000000..bba4bef
--- /dev/null
+++ b/roles/git/files/etc/systemd/system/cgit.socket
@@ -0,0 +1,11 @@
+[Unit]
+Description=hyperfast web frontend for git repositories written in C
+Documentation=https://git.zx2c4.com/cgit/
+
+[Socket]
+ListenStream=%t/cgit.socket
+SocketUser=www-data
+SocketMode=0600
+
+[Install]
+WantedBy=sockets.target
diff --git a/roles/git/files/etc/systemd/system/git-http-backend.service b/roles/git/files/etc/systemd/system/git-http-backend.service
new file mode 100644
index 0000000..f973370
--- /dev/null
+++ b/roles/git/files/etc/systemd/system/git-http-backend.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=Git HTTP backend
+Documentation=man:git-http-backend(1)
+
+[Service]
+DynamicUser=yes
+SupplementaryGroups=gitolite
+ExecStart=/usr/sbin/fcgiwrap
+SyslogIdentifier=git-http-backend
+#
+# Hardening
+NoNewPrivileges=yes
+PrivateDevices=yes
+ProtectHome=yes
+ProtectSystem=strict
+ProtectControlGroups=yes
+ProtectKernelModules=yes
+ProtectKernelTunables=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/git/files/etc/systemd/system/git-http-backend.socket b/roles/git/files/etc/systemd/system/git-http-backend.socket
new file mode 100644
index 0000000..c2820d4
--- /dev/null
+++ b/roles/git/files/etc/systemd/system/git-http-backend.socket
@@ -0,0 +1,11 @@
+[Unit]
+Description=Git HTTP backend
+Documentation=man:git-http-backend(1)
+
+[Socket]
+ListenStream=%t/git-http-backend.socket
+SocketUser=www-data
+SocketMode=0600
+
+[Install]
+WantedBy=sockets.target
diff --git a/roles/git/files/etc/uwsgi/apps-available/cgit.ini b/roles/git/files/etc/uwsgi/apps-available/cgit.ini
deleted file mode 100644
index 2fb5b25..0000000
--- a/roles/git/files/etc/uwsgi/apps-available/cgit.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[uwsgi]
-plugins = cgi
-procname-master = uwsgi %(deb-confname)
-cgi = /usr/lib/cgit/cgit.cgi
-uid = cgit
-gid = www-data
diff --git a/roles/git/files/etc/uwsgi/apps-available/git-http-backend.ini b/roles/git/files/etc/uwsgi/apps-available/git-http-backend.ini
deleted file mode 100644
index 326d6d6..0000000
--- a/roles/git/files/etc/uwsgi/apps-available/git-http-backend.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[uwsgi]
-plugins = cgi
-procname-master = uwsgi %(deb-confname)
-cgi = /usr/lib/git-core/git-http-backend
-
-# XXX regression in git-http-backend
-# https://www.mail-archive.com/git@vger.kernel.org/msg119603.html
-cgi-close-stdin-on-eof = true