# nginx config: reverse proxy to borgstore repos. # # A regex location extracts the repo name from the URL and maps it directly # to the Unix socket at /run/borgstore/.sock. # Adding a new repo requires only the env file and socket unit. # # Client usage (borg speaks to nginx, nginx proxies to borgstore): # borg -r http://backup.example.com/repos/repo1/ repo-create ... # borg -r http://backup.example.com/repos/repo2/ repo-create ... server { listen 80; server_name backup.example.com localhost; # Borgstore chunks can be large; 0 = no limit. client_max_body_size 0; # Route /repos//... to /run/borgstore/.sock # # Named captures: # $repo — repo name (restricted to safe characters to block traversal) # $rest — remainder of path forwarded to borgstore (always starts with /) # # Example: # POST /repos/myrepo/?cmd=create # → unix:/run/borgstore/myrepo.sock URI: /?cmd=create # GET /repos/myrepo/data/ab/cdef1234 # → unix:/run/borgstore/myrepo.sock URI: /data/ab/cdef1234 # location ~ ^/repos/(?[a-zA-Z0-9_.-]+) { rewrite ^/repos/[^/]+(/.*|)$ $1 break; proxy_pass http://unix:/run/borgstore/$repo.sock; include /etc/nginx/snippets/borgstore-proxy.conf; } }