This post provides some redundancy since the Docker-provided reference to the example doesn’t have a lot of surface area.
It’s not entirely straight-forward how to configure Nginx to forward requests to your Registry instance, as several options are required, for Registry compatibility.
Starting the Registry (for your reference). In this case, we’re storing our images in S3, and forwarding from port 5001 on the host system to 5000 on the Docker container:
sudo /usr/local/bin/docker run -d -e SETTINGS_FLAVOR=s3 -e AWS_BUCKET=deploy-docker_images -e STORAGE_PATH=/registry -e AWS_KEY=<your AWS access-key> -e AWS_SECRET=<your AWS secret-key> -e SEARCH_BACKEND=sqlalchemy -p 5001:5000 registry
This is the Nginx config, with help from the Docker example:
server { listen 5000; server_name localhost; ssl on; ssl_certificate /etc/ssl/certs/your.certificate.pem; ssl_certificate_key /etc/ssl/private/your.private_key.pem; client_max_body_size 0; # disable any limits to avoid HTTP 413 for large image uploads # required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486) chunked_transfer_encoding on; location / { proxy_pass http://127.0.0.1:5001; proxy_set_header Host $http_host; # required for docker client's sake proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP proxy_set_header Authorization ""; # see https://github.com/dotcloud/docker-registry/issues/170 proxy_read_timeout 900; } }