docker compose Nginx HTTPS + Nexus 3 + LDAP + Docker Registry

vhosts.conf

upstream nexus_admin { server 127.0.0.1:8081 ; }
upstream nexus_registry { server 127.0.0.1:5001 ; }

server {
    listen 80;
    listen 443 ssl http2;
    server_name docker.domain.com;
    access_log  /dev/null;
    error_log   /app/logs/nginx/docker.domain.com.error.log;
    ssl_certificate      server.pem;
    ssl_certificate_key  server.key;
    ssl_session_timeout  20m;
    ssl_protocols  TLSv1  TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers EECDH+AES:EECDH+CHACHA20;
    add_header X-Frame-Options SAMEORIGIN;

    location ~ ^/(v1|v2)/ { proxy_pass http://nexus_registry;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
    location / {
        client_max_body_size 0;
        chunked_transfer_encoding on;
        add_header Docker-Distribution-Api-Version: registry/2.0 always;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        if ($http_user_agent ~*  "docker|jib|curl|Java")   { proxy_pass http://nexus_registry; }
        if ($http_user_agent ~* "Chrome|Mozilla|Firefox")   { proxy_pass http://nexus_admin; }
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   X-Forwarded-Port $server_port;
        proxy_redirect off;
    }
}

docker-compose.yml

version: "2"

services:
  nexus:
    image: dockerhub.azk8s.cn/sonatype/nexus3:3.21.1
    volumes:
      - "/app/srv/docker/nexus3:/nexus-data"
    ports:
      - "8081:8081"
      - "8082:8082"
      - "5001:5001"
    environment:
#    - NEXUS_CONTEXT=nexus
    - JAVA_OPTS=" -Xmx2048m"
    mem_limit: 2g
    mem_swappiness: 0


## chown -Rv 200 /app/srv/docker/nexus3

## admin/admin123

Repository :
Create a new docker hosted Repository , HTTP Port 5001

LDAP ****IPA:
Search Base: cn=accounts,dc=domain,dc=com
BaseDN: cn=users
Ojbect Class: inetorgperson
Group Type: Dynamic Groups

uid=readonly,cn=users,cn=accounts,dc=domain,dc=com

filter: memberof=cn=nexus,cn=groups,dc=accounts,dc=domain,dc=com
RealName displayname or cn

User and Role map:
Role >> Create Role >> External role map >> LDAP

Enable REALM:
Security -> Realms -> enable Docker Bearer Token Realm
note: if not enable this realm, valid user auth 401 when repo "Allow anonymous docker pull"

ALLOW Anonymous access:
SECURITY --> Anonymous -->
[X] Allow anonymous users to access the server
Username: anonymous
Realm: Local Authenticating Realm

Repositories --> repo-name
[X] Allow anonymous docker pull

cmd:
docker pull ubuntu:18.04
docker login nexus.domain.com
docker tag ubuntu:18.04 nexus.domain.com/ubuntu:18.04

https://help.sonatype.com/display/NXRM3/LDAP
https://help.sonatype.com/display/NXRM3/Roles
https://help.sonatype.com/display/NXRM3/Privileges

public repo:
gradle  https://plugins.gradle.org/m2
central https://repo1.maven.org/maven2/
jcenter https://jcenter.bintray.com/
soap-ui http://smartbearsoftware.com/repository/maven2/

qcloud            http://mirrors.cloud.tencent.com/nexus/repository/maven-public/



docker repo:
https://registry-1.docker.io  https://index.docker.io/
https://registry.cn-hangzhou.aliyuncs.com

kubernetes-apt: https://mirrors.ustc.edu.cn/kubernetes/apt/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,067评论 19 139
  • 一、Docker 简介 Docker 两个主要部件:Docker: 开源的容器虚拟化平台Docker Hub: 用...
    R_X阅读 4,415评论 0 27
  • jHipster - 微服务搭建 CC_简书[https://www.jianshu.com/u/be0d56c4...
    quanjj阅读 846评论 0 2
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,596评论 2 45
  • 1、Activity,fragment的生命周期 http://blog.csdn.net/wuyinlei/ar...
    菜鸟_一枚阅读 561评论 0 7