forked from a-langer/nexus-sso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_location.conf
68 lines (58 loc) · 2.38 KB
/
docker_location.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# See https://gist.github.com/abdennour/74c5de79e57a47f3351217d674238da8?permalink_comment_id=4188452#gistcomment-4188452
location ~ ^/api/(.*) {
rewrite ^/api/(.*)$ /$1$is_args$args last;
}
# Global auth, ex.: docker login nexus_host -u admin -p XXXXXXXX
location ~ ^/(v1|v2)/(|token)$ {
proxy_pass http://nexus-node/repository/docker-login/$1/$2$is_args$args;
}
# Global search, ex.: docker search nexus_host/myrepo/image:latest
location ~ ^/(v1|v2)/(_ping|_catalog|search)$ {
set $ver $1;
set $dest $2;
set $repo 'docker-group';
if ( $arg_q ~* "^(.*?)%2F(.+$)$" ) {
set $repo $1; # repository name from query
set $args q=$2&n=$arg_n;
}
if ( $dest ~* "_catalog" ) {
set $repo 'docker-group';
set $args '';
}
proxy_pass "http://nexus-node/repository/${repo}/${ver}/${dest}${is_args}${args}";
set $repo 'docker-root';
set $args q=$arg_q&n=$arg_n;
error_page 400 404 500 = @search_fallback;
proxy_intercept_errors on;
recursive_error_pages on;
}
location @search_fallback {
proxy_pass "http://nexus-node/repository/${repo}/${ver}/${dest}${is_args}${args}";
}
# Pushing to hosted docker-root repo, ex.: docker push nexus_host/image:latest
location ~ ^/(v1|v2)/([-_0-9a-z\.]+)/blobs/uploads/$ {
proxy_pass http://nexus-node/repository/docker-root/$1/$2/blobs/uploads/$is_args$args;
proxy_hide_header Location;
add_header Location $response_header_location always;
}
# Pulling from hosted docker-root repo, ex.: docker pull nexus_host/image:latest
location ~ ^/(v1|v2)/([-_0-9a-z\.]+)/(blobs/sha256.*|manifests/.*)$ {
proxy_pass http://nexus-node/repository/docker-root/$1/$2/$3$is_args$args;
proxy_hide_header Location;
add_header Location $response_header_location always;
}
# Pushing to specific repo, ex.: docker push nexus_host/myrepo/image:latest
location ~ ^/(v1|v2)/([-_0-9a-z\.]+)/(.*)/blobs/uploads/$ {
proxy_pass http://nexus-node/repository/$2/$1/$3/blobs/uploads/$is_args$args;
proxy_hide_header Location;
add_header Location $response_header_location always;
}
# Pulling from specific repo, ex.: docker pull nexus_host/myrepo/image:latest
location ~ ^/(v1|v2)/([-_0-9a-z\.]+)/(.*)$ {
proxy_pass http://nexus-node/repository/$2/$1/$3$is_args$args;
proxy_hide_header Location;
add_header Location $response_header_location always;
}
location / {
proxy_pass http://nexus-node/;
}