Skip to content

Commit a36e3aa

Browse files
authored
docs: improve examples/read-only-auth (#371)
* Improve `examples/read-only-auth` * Update examples/read-only-auth/nginx.conf
1 parent 7025df6 commit a36e3aa

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

examples/read-only-auth/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
This example will override the original nginx conf with read only access to the registry. You will need to rewrite all the project configuration (replaces `proxy_pass` with your own value, in this example `http://registry:5000` is fine).
44

5-
There are two htpasswd files. `read-write.htpasswd` a read and write access to the registry and `read-only.htpasswd` for a read only access.
5+
There are two htpasswd files:
66

7-
All users in `read-only.htpasswd` should be in `read-write.htpasswd`.
7+
- `write.htpasswd` for write access
8+
- `read.htpasswd` for read access
9+
10+
All users in `write.htpasswd` should also be in `read.htpasswd` so that they can read and write.
811

912
Read only user: login: `read` password: `registry`.
1013
Read and write user: login: `write` password: `registry`.

examples/read-only-auth/docker-compose.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ services:
1717
- SINGLE_REGISTRY=true
1818
volumes:
1919
- ./nginx.conf:/etc/nginx/conf.d/default.conf
20-
- ./read-write.htpasswd:/etc/nginx/auth/read-write.htpasswd:ro
21-
- ./read-only.htpasswd:/etc/nginx/auth/read-only.htpasswd
20+
- ./read-write.htpasswd:/etc/nginx/auth/write.htpasswd:ro
21+
- ./read-only.htpasswd:/etc/nginx/auth/read.htpasswd:ro
2222
depends_on:
2323
- registry
2424
networks:
2525
- registry-ui-net
2626
networks:
27-
registry-ui-net:
27+
registry-ui-net:

examples/read-only-auth/nginx.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ server {
2828
}
2929
# To add basic authentication to v2 use auth_basic setting.
3030
auth_basic "Registry realm";
31-
auth_basic_user_file /etc/nginx/auth/read-write.htpasswd;
32-
# For requests that *aren't* a PUT, POST, or DELETE
33-
limit_except PUT POST DELETE {
34-
auth_basic_user_file /etc/nginx/auth/read-only.htpasswd;
31+
auth_basic_user_file /etc/nginx/auth/read.htpasswd;
32+
# For requests that *aren't* a GET, HEAD or OPTIONS use the write file instead
33+
limit_except GET HEAD OPTIONS {
34+
auth_basic_user_file /etc/nginx/auth/write.htpasswd;
3535
}
3636

3737
proxy_pass http://registry:5000;

0 commit comments

Comments
 (0)