• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Cisco Umbrella

Enterprise network security

  • Contact Sales
  • Login
    • Umbrella Login
    • Cloudlock Login
  • Why Us
    • Why Cisco Umbrella
      • Why Try Umbrella
      • Why DNS Security
      • Why Umbrella SASE
      • Our Customers
      • Customer Stories
      • Why Cisco Secure
    • Fast Reliable Cloud
      • Global Cloud Architecture
      • Cloud Network Status
      • Global Cloud Network Activity
    • Unmatched Intelligence
      • A New Approach to Cybersecurity
      • Interactive Intelligence
      • Cyber Attack Prevention
      • Umbrella and Cisco Talos Threat Intelligence
    • Extensive Integrations
      • IT Security Integrations
      • Hardware Integrations
      • Meraki Integration
      • Cisco Umbrella and SecureX
  • Products
    • Cisco Umbrella Products
      • Cisco Umbrella Cloud Security Service
      • Recursive DNS Services
      • Cisco Umbrella SIG
      • Umbrella Investigate
      • What’s New
    • Product Packages
      • Cisco Umbrella Package Comparison
      • – DNS Security Essentials Package
      • – DNS Security Advantage Package
      • – SIG Essentials Package
      • – SIG Advantage Package
      • Umbrella Support Packages
    • Functionality
      • DNS-Layer Security
      • Secure Web Gateway
      • Cloud Access Security Broker (CASB)
      • Cloud Data Loss Prevention (DLP)
      • Cloud-Delivered Firewall
      • Cloud Malware Protection
      • Remote Browser Isolation (RBI)
    • Man on a laptop with headphones on. He is attending a Cisco Umbrella Live Demo
  • Solutions
    • SASE & SSE Solutions
      • Cisco Umbrella SASE
      • Secure Access Service Edge (SASE)
      • What is SASE
      • What is Security Service Edge (SSE)
    • Functionality Solutions
      • Web Content Filtering
      • Secure Direct Internet Access
      • Shadow IT Discovery & App Blocking
      • Fast Incident Response
      • Unified Threat Management
      • Protect Mobile Users
      • Securing Remote and Roaming Users
    • Network Solutions
      • Guest Wi-Fi Security
      • SD-WAN Security
      • Off-Network Endpoint Security
    • Industry Solutions
      • Government and Public Sector Cybersecurity
      • Financial Services Security
      • Cybersecurity for Manufacturing
      • Higher Education Security
      • K-12 Schools Security
      • Healthcare, Retail and Hospitality Security
      • Enterprise Cloud Security
      • Small Business Cybersecurity
  • Resources
    • Content Library
      • Top Resources
      • Cybersecurity Webinars
      • Events
      • Research Reports
      • Case Studies
      • Videos
      • Datasheets
      • eBooks
      • Solution Briefs
    • International Documents
      • Deutsch/German
      • Español/Spanish
      • Français/French
      • Italiano/Italian
      • 日本語/Japanese
    • Security Definitions
      • What is Secure Access Service Edge (SASE)
      • What is Security Service Edge (SSE)
      • What is a Cloud Access Security Broker (CASB)
      • Cyber Threat Categories and Definitions
    • For Customers
      • Support
      • Customer Success Webinars
      • Cisco Umbrella Studio
  • Trends & Threats
    • Market Trends
      • Hybrid Workforce
      • Rise of Remote Workers
      • Secure Internet Gateway (SIG)
    • Security Threats
      • How to Stop Phishing Attacks
      • Malware Detection and Protection
      • Ransomware is on the Rise
      • Cryptomining Malware Protection
      • Cybersecurity Threat Landscape
      • Global Cyber Threat Intelligence
    •  
    • Woman connecting confidently to any device anywhere
  • Partners
    • Channel Partners
      • Partner Program
      • Become a Partner
    • Service Providers
      • Secure Connectivity
      • Managed Security for MSSPs
      • Managed IT for MSPs
    •  
    • Person looking down at laptop. They are connecting and working securely
  • Blog
    • News & Product Posts
      • Latest Posts
      • Products & Services
      • Customer Focus
      • Feature Spotlight
    • Cybersecurity Posts
      • Security
      • Threats
      • Cybersecurity Threat Spotlight
      • Research
    •  
    • Register for a webinar - with illustration of connecting securely to the cloud
  • Contact Us
  • Umbrella Login
  • Cloudlock Login
  • Free Trial
Research

Docker private registry authentication

Author avatar of Alex IanchiciAlex Ianchici
Updated — March 5, 2020 • 3 minute read
View blog >

Security is part of everyday life. We lock our doors, protect our banking information with passwords that are usually so complicated that we tend to forget them. Using common sense to secure systems is just good practice. It’s really easy to assume that because a system is internal, there is no need to enable authentication or a secure transport for it, but in our current era of remote workers, that internal network can be quite wide.
With that in mind, we spent some time investigating various systems we’re bringing up and this week, we set out with the goal of adding authentication to our private Docker repository. As you may be aware, the Docker registry does not provide a mechanism for authentication so we decided that the easiest solution to this problem would be to add an authentication proxy in front of our image repository. In our case we decided to use Nginx over SSL coupled with an internal authentication API:
Blog post
 
This solution provided us with a few advantages:

  • allows us to use our internal authentication API
  • can be re-used to provide authentication to other systems
  • can be implemented using a Docker container (we <3 Docker)

We put together a simple authentication service and an Nginx container which we made available here (https://registry.hub.docker.com/u/opendns/).

Simple basic authentication service

As a reference for the Nginx proxy container, we built an authentication API using NodeJS, which made creating a Basic authentication service a breeze. All we need to do is to create a really simple server.js, generate a credentials file using the htpasswd utility and wrap the whole thing in a Docker container which we created with the following Dockerfile:

FROM google/nodejs
ADD . /app
WORKDIR /app
RUN npm install http-auth
EXPOSE 8000
ENV NODE_PATH /data/node_modules/
CMD ["node", "server.js"]

We then deployed and tested our service:

ubuntu@trusty-64:/basic-auth# docker build -t opendns/basic-auth-service .
ubuntu@trusty-64:/basic-auth# docker run --name simple-auth opendns/basic-auth-service
ubuntu@trusty-64:/basic-auth# docker inspect --format '{{ .NetworkSettings.IPAddress }}' simple-auth
172.17.0.40
ubuntu@trusty-64:/basic-auth# curl 172.17.0.40:8000
401 Unauthorized
ubuntu@trusty-64:/basic-auth# curl -u testuser:testpassword 172.17.0.40:8000
User authenticated successfully

You can find the full example code for the basic authentication service here and the container available here.

Nginx authentication proxy

The key component of the Nginx proxy is the configuration:

# define an /auth section to send the request to an authentication service
location = /auth {
proxy_pass {{auth_backend}};
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Docker-Token "";
}
# use the auth_request directive to redirect all requests to the /auth section above
location / {
proxy_pass {{backend}};
auth_request /auth;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_buffering off;
}

It uses the http_auth_request module which sends the user using the proxy_pass directive to our simple authentication service which either returns a 200 or a 401. The 401 Authorization response triggers the Docker client to respond with a set of credentials using basic auth. Once the credentials are accepted and the API returns a 200, nginx can send the request through to the private registry. Putting the two containers together:

ubuntu@trusty-64:/nginx-auth-proxy# docker run -d --name hello-world hello-world # run a simple web server that prints out “Hello world”
ubuntu@trusty-64:/nginx-auth-proxy# docker inspect --format '{{ .NetworkSettings.IPAddress }}' hello-world
172.17.0.41
ubuntu@trusty-64:/nginx-auth-proxy# docker run -d -e AUTH_BACKEND=http://172.17.0.40:8000 -e BACKEND=http://172.17.0.41:8081 -p 0.0.0.0:8080:80 nginx-auth
ubuntu@trusty-64:/nginx-auth-proxy# curl 0.0.0.0:8080
<html>
<head><title>401 Authorization Required</title></head>
<body bgcolor="white">
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.6.1</center>
</body>
</html>
ubuntu@trusty-64:/nginx-auth-proxy# curl -u testuser:testpassword 0.0.0.0:8080
Hello world

The only thing left to add to these containers are SSL certificates and you’re good to go! You can find the code for the Nginx authentication proxy here and the container available here. A few things to note with this solution:

  • using basic auth means that every request will hit the authentication API
  • basic auth means your credentials will be sent in the clear unless you secure your connection with SSL. NOTE: never send basic auth credentials without SSL!!! Also, Docker’s client & registry doesn’t like basic auth over HTTP.
  • access to the private registry will need to be restricted to the authentication proxy

Another interesting side effect of this solution is that enabling SSL on the private registry has reduced the amount of time it takes for each pull request as the client initially attempts to connect to port 443 before falling back to port 80 unless the port is specified in the registry URL.

Suggested Blogs

  • Cloud Application Security – Risks, Questions, Insights, and Solutions July 1, 2021 3 minute read
  • Cisco Umbrella discovers evolving, complex cyberthreats in first half of 2020 August 18, 2020 6 minute read
  • New research shows consumers want cybersecurity from service providers July 7, 2020 4 minute read

Share this blog

FacebookTweetLinkedIn

Follow Us

  • Twitter
  • Facebook
  • LinkedIn
  • YouTube

Footer Sections

What we make

  • Cloud Security Service
  • DNS-Layer Network Security
  • Secure Web Gateway
  • Security Packages

Who we are

  • Global Cloud Architecture
  • Cloud Network Status
  • Cloud Network Activity
  • OpenDNS is now Umbrella
  • Cisco Umbrella Blog

Learn more

  • Webinars
  • Careers
  • Support
  • Cisco Umbrella Live Demo
  • Contact Sales
Umbrella by Cisco
208.67.222.222+208.67.220.220
2620:119:35::35+2620:119:53::53
Sign up for a Free Trial
  • Cisco Online Privacy Statement
  • Terms of Service
  • Sitemap

© 2023 Cisco Umbrella