Docker的私人registry与多个registryurl使用nginx

我目前有系统正在使用通过nginx的私人dockerregistry,但是我想要将registry更改为一个新的位置(使用一个新的主机名)。

是否有可能使用nginx重写/redirect到新的registry的URL。

例如

我有一个registryregistry-old.domain.com ,我有一个新的registry-new.domain.com 。 我希望能够继续使用docker pull registry-old.domain.com ,但是实际上它会转到新的registryregistry-new.domain.com

我不知道这是可能的,因为你必须用registryurl来标记图像。

这是我的nginxconfiguration目前:

 # New config to cover old and new domain # Works for new, but not for the old domain server { server_name registry-old.domain.com registry-new.domain.com; location / { proxy_pass http://localhost:5000; proxy_set_header Host registry-new.domain.com; # Also tried $host proxy_set_header X-Real-IP $remote_addr; } } # Original working registry #server { # server_name registry-old.domain.com; # # location / { # proxy_pass http://oldRegistry:5000; # proxy_set_header Host $host; # proxy_set_header X-Real-IP $remote_addr; # } #} 

是的,您可以这样做,但是如果您使用的是TLS,则必须在“使用者备用名”中包含通配符为*.domain.comDNS:*.domain.com的通配符TLS证书。