跳转至

JFrogContainerRegistry

配置

打开本地浏览器,访问 serverIP:8081;用户名:admin / 密码:password

先根据提示进行初始化,然后进入左侧的系统设置 ”JFrog Container Registry“

选择 http settings,进行如下配置:

  • Docker 仓库使用 "Repository Path" 方式
  • 反向代理选择 Nginx
  • 配置使用 https
  • 端口可任意设置(例如 5000)
  • ssl 路径填写 /cert/tls.key/cert/tls.crt(与反向代理的挂载和配置有关,可自由设置)

配置完成后点击保存,例如这里生成的配置(可在界面的 View 选项中查看):

###########################################################
## this configuration was generated by JFrog Artifactory ##
###########################################################

## add ssl entries when https has been set in config
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_certificate      /cert/tls.crt;
ssl_certificate_key  /cert/tls.key;
ssl_session_cache shared:SSL:1m;
ssl_prefer_server_ciphers   on;
## server configuration
server {
    listen 5000 ssl;


    server_name jcr.local.liaosirui.com;
    if ($http_x_forwarded_proto = '') {
        set $http_x_forwarded_proto  $scheme;
    }
    ## Application specific logs
    ## access_log /var/log/nginx/jcr.local.liaosirui.com-access.log timing;
    ## error_log /var/log/nginx/jcr.local.liaosirui.com-error.log;
    rewrite ^/$ /ui/ redirect;
    rewrite ^/ui$ /ui/ redirect;
    chunked_transfer_encoding on;
    client_max_body_size 0;
    location / {
    proxy_read_timeout  2400s;
    proxy_pass_header   Server;
    proxy_cookie_path   ~*^/.* /;
    proxy_buffer_size 128k;
    proxy_buffers 40 128k;
    proxy_busy_buffers_size 128k;
    proxy_pass          http://10.244.244.103:8082;
    proxy_set_header    X-JFrog-Override-Base-Url $http_x_forwarded_proto://$host:$server_port;
    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;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Strict-Transport-Security always;

        location ~ ^/artifactory/ {
            proxy_pass    http://10.244.244.103:8081;
        }
    }
}

配置反向代理

创建证书文件夹

mkdir -p $JFROG_HOME/artifactory-proxy/cert

依次创建证书所需文件

cat << _EOF_ > $JFROG_HOME/artifactory-proxy/cert/tls.key

_EOF_

cat << _EOF_ > $JFROG_HOME/artifactory-proxy/cert/tls.crt

_EOF_

创建 nginx 配置文件夹:

mkdir -p $JFROG_HOME/artifactory-proxy/conf

创建 nginx 主配置文件 $JFROG_HOME/artifactory-proxy/conf/nginx.conf,内容如下:

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/artifactory.conf;
}

按照 artifactory 生成的配置文件配置 $JFROG_HOME/artifactory-proxy/conf/artifactory.conf

拉取所需镜像

docker pull docker.io/library/nginx:1.23.2-alpine

新建 nginx 的配置文件

docker run \
 --name artifactory-proxy \
 -itd \
  --restart=always \
  -v $JFROG_HOME/artifactory-proxy/cert:/cert \
  -v $JFROG_HOME/artifactory-proxy/conf/nginx.conf:/etc/nginx/nginx.conf \
  -v $JFROG_HOME/artifactory-proxy/conf/artifactory.conf:/etc/nginx/conf.d/artifactory.conf \
  docker.io/library/nginx:1.23.2-alpine