1563474744537.jpeg

直接用nginx加ssl壳是不行的,会报如下错误:

WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://harbor/v2/: remote error: tls: internal error

先修改harbor.cfg

hostname = xxx
ui_url_protocol = https
ssl_cert = /opt/harbor/ssl/xxx.pem
ssl_cert_key = /opt/harbor/ssl/xxx.key
./prepare
docker-compose down
docker-compose up -d

此时即可实现https访问。
放到公网:
在nginx上加hosts: harborip xxx
在ng中加入https配置:

server
    {
        listen 443 ssl;
        add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
        ssl_certificate /web/ssl/xxx.pem;
        ssl_certificate_key /web/ssl/xxx.key;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 1440m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
#       ssl_ciphers ALL:!kEDH!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
        ssl_session_tickets on;
        ### openssl rand -out session_ticket.key 48
        ssl_session_ticket_key /web/ssl/session_ticket.key;
        server_name xxx;
        location / {
                proxy_pass https://xxx/;
                proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for;
                setReal http_x_forwarded_for;
                if (Real ~ (\d+)\.(\d+)\.(\d+)\.(\d+),(.*) ){
                        set Real1.2.3.4;
                }
                proxy_set_header X-Real-IpReal;
                proxy_redirect off;
                access_log /data/pwd_access.log;
                error_log /data/pwd_error.log;
        }

2 对 “harbor增加https访问”的想法;

  1. 我们是在harbor.cfg里面直接写上https://域名
    加上证书
    然后启动

    1. 对,harbor目录配证书可以的;我们的需求是增加域名代理情况下搞的

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code