Skip to content

Commit 9a3beba

Browse files
committed
Allow override with own authentication if provided (rpardini#61)
1 parent ce3c77b commit 9a3beba

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
@@ -94,6 +94,9 @@ ENV MANIFEST_CACHE_SECONDARY_TIME="60d"
9494
# In the default config, :latest and other frequently-used tags will get this value.
9595
ENV MANIFEST_CACHE_DEFAULT_TIME="1h"
9696

97+
# Should we allow overridding with own authentication, default to false.
98+
ENV ALLOW_OWN_AUTH="false"
99+
97100
# Should we allow actions different than pull, default to false.
98101
ENV ALLOW_PUSH="false"
99102

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ for this to work it requires inserting a root CA certificate into system trusted
7979
- Expose port 3128 to the network
8080
- Map volume `/docker_mirror_cache` for up to `CACHE_MAX_SIZE` (32gb by default) of cached images across all cached registries
8181
- Map volume `/ca`, the proxy will store the CA certificate here across restarts. **Important** this is security sensitive.
82+
- 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).
8283
- 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).
8384
- 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).
8485
- Env `ENABLE_MANIFEST_CACHE`, see the section on pull rate limiting.

entrypoint.sh

+11
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,17 @@ echo -e "\nManifest caching config: ---\n"
137137
cat /etc/nginx/nginx.manifest.caching.config.conf
138138
echo "---"
139139

140+
if [[ "a${ALLOW_OWN_AUTH}" == "atrue" ]]; then
141+
cat << 'EOF' > /etc/nginx/conf.d/allowed_override_auth.conf
142+
if ($http_authorization != "") {
143+
# override with own authentication if provided
144+
set $finalAuth $http_authorization;
145+
}
146+
EOF
147+
else
148+
echo '' > /etc/nginx/conf.d/allowed_override_auth.conf
149+
fi
150+
140151
if [[ "a${ALLOW_PUSH}" == "atrue" ]]; then
141152
cat <<EOF > /etc/nginx/conf.d/allowed.methods.conf
142153
# allow to upload big layers

nginx.conf

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

247247
# Add the authentication info, if the map matched the target domain.
248+
include "/etc/nginx/conf.d/allowed_override_auth.conf";
248249
proxy_set_header Authorization $finalAuth;
249250

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

0 commit comments

Comments
 (0)