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 ;
    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 / {
        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")               { proxy_pass http://nexus_registry; }
        if ($http_user_agent ~* "Chrome|Mozilla")   { 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: sonatype/nexus3:3.6.0
    volumes:
      - "/app/srv/docker/nexus3:/nexus-data"
    ports:
      - "8081:8081"
      - "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 FreeIPA:
Search Base: cn=accounts,dc=domain,dc=com
BaseDN: cn=users
Ojbect Class: inetorgperson
Group Type: Dynamic Groups

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

enable REALM:
Docker Bearer Token Realm

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

你可能感兴趣的:(Nginx HTTPS + Nexus 3 + LDAP + Docker Registry)