Nginx configuration for docker repos in Artifactory

I have the following conf for nginx to set up docker repos in artifactory

upstream artifactory_lb {
        server backup_artifactory_server:8081 backup;
        server main_artifactory_server:8081;


log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name  to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';

ssl_certificate  /etc/nginx/ssl/myCert.pem
ssl_certificate_key /etc/nginx/ssl/myKey
ssl_protocols TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:10m;

server {
        listen 80;
        listen 443  ssl;
        client_max_body_size 2048M;
        location / {
                proxy_set_header Host $host;
                proxy_pass http://artifactory_lb;
                proxy_read_timeout 90;
        access_log /var/log/nginx/access.log upstreamlog;
        location /basic_status {
                stub_status on;
                allow all;

# Server configuration

server {
    listen 2222 ssl;
    if ($http_x_forwarded_proto = '') {
        set $http_x_forwarded_proto  $scheme;

    rewrite ^/(v1|v2)/(.*) /api/docker/inhouse_images/$1/$2;
    client_max_body_size 0;
    chunked_transfer_encoding on;

    location / {
    allow all;
    proxy_read_timeout  900;
    proxy_pass_header   Server;
    proxy_cookie_path ~*^/.* /;
    proxy_set_header   X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host;
    proxy_set_header    X-Forwarded-Port  $server_port;
    proxy_set_header    X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header    Host              $http_host;
    proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
     # proxy_pass http://artifactory_lb;
    proxy_pass http://backup_artifactory_server:8081/artifactory/;


This works fine, although, by setting the ‘proxy_pass’ directive to point to the loadbalancer instance introduces a single point failure. Why does it need to be routed to ‘/artifactory’?

  • Cannot (apt-get) install packages inside docker
  • python2 interpreter in Docker does not support remote project creation with PyCharm
  • Docker for Mac. docker run -d -p 80:80 --name webserver nginx shows another container with this name. but docker ps shows empty list
  • How do I build docker images when my development environment mounts my codebase into the container?
  • How to get the Docker version using the Remote API
  • How to perform checkpoint and restore of docker containers across two hosts?
  • What will be the best way to fix this? Creating a new group of upstream servers seems redundant

  • Updating Short and Full Descriptions on Docker Hub
  • Is there a way to add only changed files to a docker image as a new layer - without resorting to docker commit?
  • Docker not reporting memory usage correctly?
  • Docker-compose fails with error “No command specified”
  • Google Container Engine: Accessing Cloud Storage
  • Docker-compose config front-end with back-end's IP from host's perspective
  • One Solution collect form web for “Nginx configuration for docker repos in Artifactory”

    I fixed this by changing the following

     rewrite ^/(v1|v2)/(.*) /api/docker/inhouse_images/$1/$2;

    To the following

     rewrite ^/(v1|v2)/(.*) /artifactory/api/docker/inhouse_images/$1/$2;

    And pointing the proxy_pass directive to the upstream servers

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.