2017-06-07 279 views
1

我目前正在嘗試將nexus作爲我的組織內泊塢窗圖像的私有註冊表。我的nginx配置如下。Nginx Docker 400錯誤請求

user nginx; 
worker_processes 1; 

error_log /var/log/nginx/error.log warn; 
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; 

    server { 

      listen 6666; ### Docker Hosted Repo HTTPS port 
      server_name server408.int.org.com; ### Nexus Server 
      keepalive_timeout 60; 

      ssl on; 
      ssl_certificate /etc/ssl/certs/clsanexus.crt; 
      ssl_certificate_key /etc/ssl/certs/clsanexus.key; 
      ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH; 
      ssl_session_cache shared:TLSSSL:16m; 
      ssl_session_timeout 10m; 
      ssl_prefer_server_ciphers on; 

      client_max_body_size 0; 
      chunked_transfer_encoding on; 

      location /v2/ { 


        if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go).*$") { 
        return 404; 
        } 
        error_log    /var/log/nginx/error.log debug; 
        access_log    /var/log/nginx/docker.log; 
        proxy_set_header  Host $http_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 "https"; 
        proxy_pass    http://server408.int.org.com:4444/; 
        proxy_read_timeout  900; 
     } 

      location/{ 

        error_log    /var/log/nginx/error.log debug; 
        access_log    /var/log/nginx/docker.log; 
        proxy_set_header  Host $http_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 "https"; 
        proxy_pass    http://server408.int.org.com:4444/; 
        proxy_read_timeout  90; 
     } 
    } 

有沒有和HTTPS端口6666

配置的關係(在端口4444上運行)內的託管泊塢窗式回購目前,我們能夠登錄到泊塢窗註冊表。

[dockertest @ vserver446〜] $搬運工登錄-u管理-p爲admin123 server408.int.org.com:6666登錄成功

但是,當我們試圖標記的圖像推到關係託管碼頭註冊表它會拋出400錯誤請求錯誤。

[dockertest @ server446〜] $搬運工推server.int.org.com:6666/alpine 推指庫[server408.int.org.com:6666/alpine] 3fb66f713c9f:準備錯誤解析HTTP 400響應正文:無效 字符'<'查找值的開始:「\ n \ n \ n \ n 400 - Nexus存儲庫 管理器\ n \ n \ n \ n \ n (新的 圖片) .src = \「https://server408.int.org.com:6666/favicon.ico?3.2.1-01 \」</script> \ n \ n https://vklnld908.int.clsa.com :6666/favicon-32x32.png?3.2.1-01 \「 sizes = \」32x32 \「> \ n https://server408.int.org.com:666 6/safari-pinned-tab.svg?3.2.1-01 \「color = \」#5bbad5 \「> \ n https://server408.int.org.com:6666/favicon-16x16.png?3.2。 1-01 \「 sizes = \」16x16 \「> \ n https://server408.int.org.com:6666/favicon.ico?3.2.1-01\">\n https:// server408 .int.org.com:6666/mstile-144x144.png?3.2.1-01 \「> \ n \ n \ n https://vklnld908.int.clsa.com:6666/static/css/nexus-content .css?3.2.1-01 \「/> \ n \ n \ n \ n https://server408.int.org.com:6666\"> \ n \ n https://server408.int.org。 com:6666/static/images/nexus.png?3.2.1-01 \「/> \ n \ n \ n \ n Nexus Repository Manager \ n \ n \ n OSS 3.2.1-01 \ n \ n \ n \ n \ n \ n \ n \ n https://server408.int.org.com:6666/static/rapture/resources/icons/x32/exclamation.png?3.2.1-01 \「/> \ n 錯誤400 \ n錯誤請求\ n \ n \ n \ n
HTTP方法POST不受此URL支持\ n \ n
\ n \ n \ n \ n \ n」個

我丟失了一些重要的nginx的配置?或者我的請求格式不正確。

+0

也許https://serverfault.com是一個更好的地方來問這樣的問題。 – reporter

+0

順便說一句:在錯誤消息結束時,您可以找到「錯誤400 \ n錯誤請求\ n \ n \ n \ n HTTP方法POST不受此URL支持」。也許這會讓你走向正確的方向。 – reporter

+0

但它沒有指定它形成的網址發佈圖像 –

回答

0

它的嘗試,現在的工作。以下是我的nginx配置。

server { 

    proxy_send_timeout 120; 
    proxy_read_timeout 300; 
    proxy_buffering off; 
    tcp_nodelay  on; 

    server_tokens off; 
    client_max_body_size 1G; 

    listen 80; 
    server_name server908.int.org.com; 
    location/{ 
      rewrite ^(.*) https://server908.int.org.com$1 permanent; 
    } 
} 

server { 

    listen 443; 
    server_name server908.int.org.com; 
    keepalive_timeout 60; 
    ssl on; 
    ssl_certificate /etc/ssl/certs/orgnexus.crt; 
    ssl_certificate_key /etc/ssl/certs/orgnexus.key; 
    ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH; 
    ssl_session_cache shared:TLSSSL:16m; 
    ssl_session_timeout 10m; 
    ssl_prefer_server_ciphers on; 

    location/{ 

     proxy_set_header  Host $http_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 "https"; 
     proxy_pass    http://server908.int.org.com:8082; 
     proxy_read_timeout  90; 

    } 
} 

# correlates to your nexus http connector 
server { 

    listen 6666; 
    server_name server908.int.org.com; 
    keepalive_timeout 60; 
    ssl on; 
    ssl_certificate /etc/ssl/certs/orgnexus.crt; 
    ssl_certificate_key /etc/ssl/certs/orgnexus.key; 
    ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH; 
    ssl_session_cache shared:TLSSSL:16m; 
    ssl_session_timeout 10m; 
    ssl_prefer_server_ciphers on; 
    client_max_body_size 1G; 
    chunked_transfer_encoding on; 

    ### Block for Search,Pull,Push of Docker Images via Nexus Hosted Repo #### 
    location/{ 

     access_log    /var/log/nginx/docker.log; 
     proxy_set_header  Host $http_host; 
     proxy_set_header  X-Real-IP $remote_addr; 
     proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for; 

     if ($request_method !~* GET) { 
       proxy_pass    http://server908.int.org.com:4444; 
     } 
     if ($request_method = GET) { 
       proxy_pass    http://server908.int.org.com:5555; 
     } 
     proxy_read_timeout  90; 
    } 
}