Skip to content
This repository was archived by the owner on Dec 29, 2024. It is now read-only.

Commit 7e9577e

Browse files
gw0kiorky
authored andcommitted
Allow override with own authentication if provided (rpardini#61)
1 parent fcf8fc1 commit 7e9577e

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
@@ -147,6 +147,17 @@ echo -e "\nManifest caching config: ---\n"
147147
cat /etc/nginx/nginx.manifest.caching.config.conf
148148
echo "---"
149149

150+
if [[ "a${ALLOW_OWN_AUTH}" == "atrue" ]]; then
151+
cat << 'EOF' > /etc/nginx/conf.d/allowed_override_auth.conf
152+
if ($http_authorization != "") {
153+
# override with own authentication if provided
154+
set $finalAuth $http_authorization;
155+
}
156+
EOF
157+
else
158+
echo '' > /etc/nginx/conf.d/allowed_override_auth.conf
159+
fi
160+
150161
if [[ "a${ALLOW_PUSH}" == "atrue" ]]; then
151162
cat <<EOF > /etc/nginx/conf.d/allowed.methods.conf
152163
# 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)