progmaweb
The site and account service of Progmasoft: a Next.js frontend and an ASP.NET Core API.
Clonegit clone https://git.progmasoft.com/progmaweb
mainroot / ops / git / nginx / git.conf
# SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
# https://git.progmasoft.com: the pages of the read-only mirrors from the Next.js site of Progmaweb,
# raw files and archives from its API, and clones over smart HTTP with git-http-backend
# (upload-pack only). Installed as /etc/nginx/conf.d/git.conf.
limit_req_zone $binary_remote_addr zone=git_pages:10m rate=10r/s;
limit_req_zone $binary_remote_addr zone=git_clones:10m rate=1r/s;
limit_conn_zone $binary_remote_addr zone=git_connections:10m;
server {
listen 80;
listen [::]:80;
server_name git.progmasoft.com;
location ^~ /.well-known/acme-challenge/ {
root /var/lib/letsencrypt;
default_type text/plain;
}
location / {
return 308 https://git.progmasoft.com$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name git.progmasoft.com;
ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
# Nothing is uploaded here: a clone sends only the list of what it wants.
client_max_body_size 1m;
limit_conn git_connections 8;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
# Next.js gives every page its own content security policy with a nonce; the API gives raw files
# and archives one that allows nothing.
# Pushing is never possible: no receive-pack, and the dumb protocol is off.
location ~ ^/[A-Za-z0-9._-]+/git-receive-pack$ {
return 403;
}
location ~ ^/(?<git_repo>[A-Za-z0-9._-]+?)(?:\.git)?/(?<git_path>info/refs|git-upload-pack)$ {
set $git_service "";
if ($git_path = "info/refs") {
set $git_service $arg_service;
}
if ($git_path = "git-upload-pack") {
set $git_service "git-upload-pack";
}
if ($git_service != "git-upload-pack") {
return 403;
}
limit_req zone=git_clones burst=10 nodelay;
fastcgi_pass unix:/run/fcgiwrap/fcgiwrap-githttp.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
fastcgi_param GIT_PROJECT_ROOT /srv/git/mirrors;
# No GIT_HTTP_EXPORT_ALL: only mirrors git-mirror marks with git-daemon-export-ok are served.
fastcgi_param PATH_INFO /$git_repo.git/$git_path;
fastcgi_param REMOTE_USER "";
# The mirrors belong to gitmirror and are read as the user of the fcgiwrap instance; only this
# backend trusts them.
fastcgi_param GIT_CONFIG_COUNT 1;
fastcgi_param GIT_CONFIG_KEY_0 safe.directory;
fastcgi_param GIT_CONFIG_VALUE_0 /srv/git/mirrors/*;
fastcgi_read_timeout 300s;
# Nginx buffers the pack (to a file when it is large), so a slow reader never stalls
# git-http-backend behind fcgiwrap.
fastcgi_buffering on;
fastcgi_max_temp_file_size 2048m;
}
# Raw files and archives come from the API; the name is a repository name, and the API checks
# it against the catalog.
location ~ ^/(?<git_name>[A-Za-z0-9_-][A-Za-z0-9._-]*)/(?<git_view>raw|archive)$ {
limit_req zone=git_pages burst=40 nodelay;
proxy_pass http://127.0.0.1:5085/api/v1/git/repositories/$git_name/$git_view$is_args$args;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 120s;
}
# Every other path is a page of the Next.js site.
location / {
limit_req zone=git_pages burst=40 nodelay;
proxy_pass http://127.0.0.1:3010;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 60s;
}
}