Skip to content

Instantly share code, notes, and snippets.

@kwokhou
Last active September 5, 2016 02:17
Show Gist options
  • Save kwokhou/42eb32ca6c0ba2b25fd193f017ef7908 to your computer and use it in GitHub Desktop.
Save kwokhou/42eb32ca6c0ba2b25fd193f017ef7908 to your computer and use it in GitHub Desktop.
Nginx conf for Docker Registry
upstream docker-registry {
server registry:5000;
}
server {
listen 80;
server_name mydomain.com;
root /etc/nginx/html;
index index.html index.htm index.nginx-debian.html;
location ^~ /.well-known/ {
allow all;
}
}
server {
listen 443;
server_name mydomain.com;
ssl on;
ssl_certificate /etc/nginx/conf.d/domain.crt;
ssl_certificate_key /etc/nginx/conf.d/domain.key;
client_max_body_size 0;
chunked_transfer_encoding on;
location /v2/ {
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
return 404;
}
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/conf.d/htpasswd;
add_header 'Docker-Distribution-API-Version' 'registry/2.0' always;
proxy_pass http://docker-registry;
proxy_read_timeout 900;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment