| 1 |
# nginx config: reverse proxy to borgstore repos. |
| 2 |
# |
| 3 |
# A regex location extracts the repo name from the URL and maps it directly |
| 4 |
# to the Unix socket at /run/borgstore/<name>.sock. |
| 5 |
# Adding a new repo requires only the env file and socket unit. |
| 6 |
# |
| 7 |
# Client usage (borg speaks to nginx, nginx proxies to borgstore): |
| 8 |
# borg -r http://backup.example.com/repos/repo1/ repo-create ... |
| 9 |
# borg -r http://backup.example.com/repos/repo2/ repo-create ... |
| 10 |
|
| 11 |
server { |
| 12 |
listen 80; |
| 13 |
server_name backup.example.com localhost; |
| 14 |
|
| 15 |
# Borgstore chunks can be large; 0 = no limit. |
| 16 |
client_max_body_size 0; |
| 17 |
|
| 18 |
# Route /repos/<name>/... to /run/borgstore/<name>.sock |
| 19 |
# |
| 20 |
# Named captures: |
| 21 |
# $repo — repo name (restricted to safe characters to block traversal) |
| 22 |
# $rest — remainder of path forwarded to borgstore (always starts with /) |
| 23 |
# |
| 24 |
# Example: |
| 25 |
# POST /repos/myrepo/?cmd=create |
| 26 |
# → unix:/run/borgstore/myrepo.sock URI: /?cmd=create |
| 27 |
# GET /repos/myrepo/data/ab/cdef1234 |
| 28 |
# → unix:/run/borgstore/myrepo.sock URI: /data/ab/cdef1234 |
| 29 |
# |
| 30 |
location ~ ^/repos/(?<repo>[a-zA-Z0-9_.-]+) { |
| 31 |
rewrite ^/repos/[^/]+(/.*|)$ $1 break; |
| 32 |
proxy_pass http://unix:/run/borgstore/$repo.sock; |
| 33 |
include /etc/nginx/snippets/borgstore-proxy.conf; |
| 34 |
} |
| 35 |
} |