Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit 3be0e0b

Browse files
committed
Merge pull request #458 from bacongobbler/230-auth-basic
add auth basic to nginx configuration
2 parents 91afcb1 + b498a42 commit 3be0e0b

File tree

2 files changed

+58
-12
lines changed

2 files changed

+58
-12
lines changed

contrib/nginx.conf

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,27 @@ upstream docker-registry {
77
server localhost:5000;
88
}
99

10+
# uncomment if you want a 301 redirect for users attempting to connect
11+
# on port 80
12+
# NOTE: docker client will still fail. This is just for convenience
13+
# server {
14+
# listen *:80;
15+
# server_name my.docker.registry.com;
16+
# return 301 https://$server_name$request_uri;
17+
# }
18+
1019
server {
1120
listen 443;
1221
server_name my.docker.registry.com;
1322

1423
ssl on;
1524
ssl_certificate /etc/ssl/certs/docker-registry;
1625
ssl_certificate_key /etc/ssl/private/docker-registry;
17-
18-
proxy_set_header Host $http_host; # required for docker client's sake
19-
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
20-
26+
27+
proxy_set_header Host $http_host; # required for docker client's sake
28+
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
29+
proxy_set_header Authorization ""; # see https://github.com/dotcloud/docker-registry/issues/170
30+
2131
client_max_body_size 0; # disable any limits to avoid HTTP 413 for large image uploads
2232

2333
# required to avoid HTTP 411: see Issue #1486 (https://github.com/dotcloud/docker/issues/1486)
@@ -26,8 +36,21 @@ server {
2636
location @my_411_error {
2737
chunkin_resume;
2838
}
29-
39+
3040
location / {
31-
proxy_pass http://docker-registry;
41+
proxy_pass http://docker-registry;
42+
proxy_set_header Host $host;
43+
proxy_read_timeout 900;
44+
45+
auth_basic "Restricted";
46+
auth_basic_user_file docker-registry.htpasswd;
47+
}
48+
49+
location /_ping {
50+
auth_basic off;
51+
}
52+
53+
location /v1/_ping {
54+
auth_basic off;
3255
}
3356
}

contrib/nginx_1-3-9.conf

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,46 @@ upstream docker-registry {
55
server localhost:5000;
66
}
77

8+
# uncomment if you want a 301 redirect for users attempting to connect
9+
# on port 80
10+
# NOTE: docker client will still fail. This is just for convenience
11+
# server {
12+
# listen *:80;
13+
# server_name my.docker.registry.com;
14+
# return 301 https://$server_name$request_uri;
15+
# }
16+
817
server {
918
listen 443;
1019
server_name my.docker.registry.com;
1120

1221
ssl on;
1322
ssl_certificate /etc/ssl/certs/docker-registry;
1423
ssl_certificate_key /etc/ssl/private/docker-registry;
15-
16-
proxy_set_header Host $http_host; # required for docker client's sake
17-
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
18-
24+
25+
proxy_set_header Host $http_host; # required for docker client's sake
26+
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
27+
proxy_set_header Authorization ""; # see https://github.com/dotcloud/docker-registry/issues/170
28+
1929
client_max_body_size 0; # disable any limits to avoid HTTP 413 for large image uploads
2030

2131
# required to avoid HTTP 411: see Issue #1486 (https://github.com/dotcloud/docker/issues/1486)
2232
chunked_transfer_encoding on;
23-
33+
2434
location / {
25-
proxy_pass http://docker-registry;
35+
proxy_pass http://docker-registry;
36+
proxy_set_header Host $host;
37+
proxy_read_timeout 900;
38+
39+
auth_basic "Restricted";
40+
auth_basic_user_file docker-registry.htpasswd;
41+
}
42+
43+
location /_ping {
44+
auth_basic off;
45+
}
46+
47+
location /v1/_ping {
48+
auth_basic off;
2649
}
2750
}

0 commit comments

Comments
 (0)