-
Notifications
You must be signed in to change notification settings - Fork 47
/
nginx.sample.conf
34 lines (29 loc) · 1.31 KB
/
nginx.sample.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# In order for this server to work, you need to install some dependencies:
# apt install nginx git fcgiwrap
#
# Also, ensure fcgiwrap is running as a daemon. On Ubuntu, this should happen automatically.
server {
listen 80 default_server;
listen [::]:80 default_server;
# Replace this with the path to your mirror directory.
root /path/to/my-mirror;
# Replace this with the domain name you're serving the mirror from.
server_name panamax.internal;
location / {
autoindex on;
}
location ~ /crates.io-index(/.*) {
# Replace this path with the path to crates.io-index in your mirror directory.
fastcgi_param GIT_PROJECT_ROOT /path/to/my-mirror/crates.io-index;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param PATH_INFO $1;
}
# Rewrite the download URLs to match the proper crates location.
rewrite "^/crates/([^/])/([^/]+)$" "/crates/1/$1/$2" last;
rewrite "^/crates/([^/]{2})/([^/]+)$" "/crates/2/$1/$2" last;
rewrite "^/crates/([^/])([^/]{2})/([^/]+)$" "/crates/3/$1/$1$2/$3" last;
rewrite "^/crates/([^/]{2})([^/]{2})([^/]*)/([^/]+)$" "/crates/$1/$2/$1$2$3/$4" last;
}