Skip to content

Commit 3a51ce3

Browse files
gw0rpardini
authored andcommitted
Allow override with own authentication if provided (rpardini#61)
1 parent e3f1eee commit 3a51ce3

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ ENV MANIFEST_CACHE_SECONDARY_TIME="60d"
9797
# In the default config, :latest and other frequently-used tags will get this value.
9898
ENV MANIFEST_CACHE_DEFAULT_TIME="1h"
9999

100+
# Should we allow overridding with own authentication, default to false.
101+
ENV ALLOW_OWN_AUTH="false"
102+
100103
# Should we allow actions different than pull, default to false.
101104
ENV ALLOW_PUSH="false"
102105

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ for this to work it requires inserting a root CA certificate into system trusted
8686
- Expose port 3128 to the network
8787
- Map volume `/docker_mirror_cache` for up to `CACHE_MAX_SIZE` (32gb by default) of cached images across all cached registries
8888
- Map volume `/ca`, the proxy will store the CA certificate here across restarts. **Important** this is security sensitive.
89+
- Env `ALLOW_OWN_AUTH` (default `false`): Allow overridding the `AUTH_REGISTRIES` authentication with own Docker credentials if provided (to support `docker login` as another user).
8990
- Env `ALLOW_PUSH` : This bypasses the proxy when pushing, default to false - if kept to false, pushing will not work. For more info see this [commit](https://github.com/rpardini/docker-registry-proxy/commit/536f0fc8a078d03755f1ae8edc19a86fc4b37fcf).
9091
- Env `CACHE_MAX_SIZE` (default `32g`): set the max size to be used for caching local Docker image layers. Use [Nginx sizes](http://nginx.org/en/docs/syntax.html).
9192
- Env `ENABLE_MANIFEST_CACHE`, see the section on pull rate limiting.

entrypoint.sh

+11
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ echo -e "\nManifest caching config: ---\n"
151151
cat /etc/nginx/nginx.manifest.caching.config.conf
152152
echo "---"
153153

154+
if [[ "a${ALLOW_OWN_AUTH}" == "atrue" ]]; then
155+
cat << 'EOF' > /etc/nginx/conf.d/allowed_override_auth.conf
156+
if ($http_authorization != "") {
157+
# override with own authentication if provided
158+
set $finalAuth $http_authorization;
159+
}
160+
EOF
161+
else
162+
echo '' > /etc/nginx/conf.d/allowed_override_auth.conf
163+
fi
164+
154165
if [[ "a${ALLOW_PUSH}" == "atrue" ]]; then
155166
cat <<EOF > /etc/nginx/conf.d/allowed.methods.conf
156167
# allow to upload big layers

nginx.conf

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
249249
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
250250

251251
# Add the authentication info, if the map matched the target domain.
252+
include "/etc/nginx/conf.d/allowed_override_auth.conf";
252253
proxy_set_header Authorization $finalAuth;
253254

254255
# Use SNI during the TLS handshake with the upstream.

0 commit comments

Comments
 (0)