nginx – 501推送到Artifactory Docker存储库时不执行

前端之家收集整理的这篇文章主要介绍了nginx – 501推送到Artifactory Docker存储库时不执行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在将Artifactory设置为Docker存储库.我遵循文档,我能够成功地从我的虚拟Docker repo中抽取图像.

但是,当我尝试将映像推送到本地存储库时,它将失败,而501未实现错误.

这是我的设置:

Nginx是反向代理:

  1. artifactory.somedomain.com:8085 -> http://localhost:8081/artifactory/api/docker/docker-local/v2
  2. artifactory.somedomain.com:8086 -> http://localhost:8081/artifactory/api/docker/docker/v2

> docker-local是本地存储库,API V2不强制认证.没有其他设置设置.
docker是一个虚拟存储库,聚合了docker-local和docker-remote(只是代理了std Docker repo)

命令运行:

  1. docker pull artifactory.somedomain.com:8086/busyBox:latest
  2. docker tag artifactory.somedomain.com:8086/busyBox artifactory.somedomain.com:8085/busyBox
  3. docker push artifactory.somedomain.com:8085/busyBox

结果是:

  1. The push refers to a repository [artifactory.somedomain.com:8085/busyBox] (len: 1)
  2. 2c5ac3f849df: Buffering to Disk
  3. Received unexpected HTTP status: 501 Not Implemented

任何想法可能是错的?
谢谢!

Nginx.conf
(前两个规则一般处理重定向http,最后两个规则处理Docker存储库的代理)

  1. # For more information on configuration,see:
  2. # * Official English Documentation: http://Nginx.org/en/docs/
  3. # * Official Russian Documentation: http://Nginx.org/ru/docs/
  4. user Nginx;
  5. worker_processes auto;
  6. error_log /var/log/Nginx/error.log;
  7. pid /run/Nginx.pid;
  8. events {
  9. worker_connections 1024;
  10. }
  11. http {
  12. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  13. '$status $body_bytes_sent "$http_referer" '
  14. '"$http_user_agent" "$http_x_forwarded_for"';
  15. access_log /var/log/Nginx/access.log main;
  16. sendfile on;
  17. tcp_nopush on;
  18. tcp_nodelay on;
  19. keepalive_timeout 65;
  20. types_hash_max_size 2048;
  21. client_max_body_size 1G;
  22. include /etc/Nginx/mime.types;
  23. default_type application/octet-stream;
  24. # Load modular configuration files from the /etc/Nginx/conf.d directory.
  25. # See http://Nginx.org/en/docs/ngx_core_module.html#include
  26. # for more information.
  27. include /etc/Nginx/conf.d/*.conf;
  28. server {
  29. listen 80;
  30. server_name artifactory.somedomain.com;
  31. return 301 https://$server_name$request_uri;
  32. }
  33. server {
  34. listen 443;
  35. server_name artifactory.somedomain.com;
  36. access_log /var/log/Nginx/artifactory.yourdomain.com.access.log;
  37. error_log /var/log/Nginx/artifactory.yourdomain.com.error.log;
  38. ssl on;
  39. ssl_certificate /etc/Nginx/cert/artifactory-cert-chain.crt;
  40. ssl_certificate_key /etc/Nginx/cert/artifactory.key;
  41. ssl_session_timeout 5m;
  42. ssl_protocols SSLv3 TLSv1;
  43. ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
  44. ssl_prefer_server_ciphers on;
  45. location / {
  46. proxy_redirect http:// https://;
  47. proxy_set_header Host $host:$server_port;
  48. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  49. proxy_set_header X-Real-IP $remote_addr;
  50. proxy_set_header X-Forwarded-Ssl on;
  51. proxy_set_header X-Forwarded-Proto $scheme;
  52. proxy_pass http://localhost:8081;
  53. proxy_pass_header Server;
  54. proxy_read_timeout 90;
  55. }
  56. }
  57. server {
  58. listen 8085;
  59. server_name artifactory.somedomain.com;
  60. ssl on;
  61. ssl_certificate /etc/Nginx/cert/artifactory-cert-chain.crt;
  62. ssl_certificate_key /etc/Nginx/cert/artifactory.key;
  63. access_log /var/log/Nginx/artprod.company.com.access.log;
  64. error_log /var/log/Nginx/artprod.company.com.error.log;
  65. proxy_set_header Host $host;
  66. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  67. proxy_set_header X-Real-IP $remote_addr;
  68. proxy_set_header X-Forwarded-Proto $scheme;
  69. proxy_set_header X-Original-URI $request_uri;
  70. proxy_pass_header Server; # To help debugging,list the server that actually did the reply rather than Nginx
  71. proxy_read_timeout 900;
  72. client_max_body_size 0; # disable any limits to avoid HTTP 413 for large image uploads
  73. # required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486)
  74. chunked_transfer_encoding on;
  75. location /v2 {
  76. # Do not allow connections from docker 1.5 and earlier
  77. # docker pre-1.6.0 did not properly set the user agent on ping
  78. if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))).*$" ) {
  79. return 404;
  80. }
  81. proxy_pass http://localhost:8081/artifactory/api/docker/docker-local/v2;
  82. }
  83. }
  84. server {
  85. listen 8086;
  86. server_name artifactory.somedomain.com;
  87. ssl on;
  88. ssl_certificate /etc/Nginx/cert/artifactory-cert-chain.crt;
  89. ssl_certificate_key /etc/Nginx/cert/artifactory.key;
  90. access_log /var/log/Nginx/artprod.company.com.access.log;
  91. error_log /var/log/Nginx/artprod.company.com.error.log;
  92. proxy_set_header Host $host;
  93. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  94. proxy_set_header X-Real-IP $remote_addr;
  95. proxy_set_header X-Forwarded-Proto $scheme;
  96. proxy_set_header X-Original-URI $request_uri;
  97. proxy_pass_header Server; # To help debugging,list the server that actually did the reply rather than Nginx
  98. proxy_read_timeout 900;
  99. client_max_body_size 0; # disable any limits to avoid HTTP 413 for large image uploads
  100. # required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486)
  101. chunked_transfer_encoding on;
  102. location /v2 {
  103. # Do not allow connections from docker 1.5 and earlier
  104. # docker pre-1.6.0 did not properly set the user agent on ping
  105. if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))).*$" ) {
  106. return 404;
  107. }
  108. proxy_pass http://localhost:8081/artifactory/api/docker/docker/v2;
  109. }
  110. }
  111. }

Nginx的访问日志显示每个请求

  1. 192.168.33.65 - - [02/Nov/2015:13:04:56 +0100] "GET /v2/ HTTP/1.1" 200 12 "-" "docker/1.8.3 go/go1.4.2 git-commit/f4bf5c7 kernel/4.1.10-boot2docker os/linux arch/amd64"
  2. 192.168.33.65 - - [02/Nov/2015:13:04:57 +0100] "HEAD /v2/busyBox/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4 HTTP/1.1" 404 0 "-" "docker/1.8.3 go/go1.4.2 git-commit/f4bf5c7 kernel/4.1.10-boot2docker os/linux arch/amd64"
  3. 192.168.33.65 - - [02/Nov/2015:13:04:57 +0100] "POST /v2/busyBox/blobs/uploads/ HTTP/1.1" 202 0 "-" "docker/1.8.3 go/go1.4.2 git-commit/f4bf5c7 kernel/4.1.10-boot2docker os/linux arch/amd64"
最佳答案
问题是Nginx的配置. Artifactory文档中提供的示例假定您正在使用HTTPS端口443连接到存储库.

如果使用不同的端口,则需要编辑listen和proxy_set_header主机指令以包含端口.

  1. server {
  2. listen

猜你在找的Nginx相关文章