Want to migrate the Docker Registry from the old one(R1) to the new one(R2). R1 already has many old images, R2 is empty but will be the only registry after R1 deprecated in the future.
All new images will be pushed into R2. When pull images, directly pull them from R2 if found in R2, otherwise pull from R1.
There is a Nginx(Harbor) in front of them, and distributes the image requests to Docker Registry. The requests are firstly directed to R2. If the image is not found in R2, there will be an 404 error, then Nginx needs to redirect this request to R1.
Test
The test url http://localhost/abcde will be directed to https://github.com/abcde. The $request_uri in nginx.conf makes the request uri kept when directed.
Background
Want to migrate the Docker Registry from the old one(R1) to the new one(R2). R1 already has many old images, R2 is empty but will be the only registry after R1 deprecated in the future. All new images will be pushed into R2. When pull images, directly pull them from R2 if found in R2, otherwise pull from R1. There is a Nginx(Harbor) in front of them, and distributes the image requests to Docker Registry. The requests are firstly directed to R2. If the image is not found in R2, there will be an 404 error, then Nginx needs to redirect this request to R1.
Example
nginx.conf
Test The test url
http://localhost/abcde
will be directed tohttps://github.com/abcde
. The$request_uri
in nginx.conf makes the request uri kept when directed.References