NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
JasonLaw
V2EX  ›  NGINX

Nginx 将 location /docker-registry proxy_pass 到 docker registry 出现“error parsing HTTP 404 response body”

  •  
  •   JasonLaw · Apr 27, 2021 · 2524 views
    This topic created in 1864 days ago, the information mentioned may be changed or developed.

    我使用 Nginx 将 /docker-registry proxy_pass 到 http://localhost:5000/,以下是配置:

    http {
       server {
          server_name ...;
          listen 443 ssl;
    
          ssl_certificate ...;
          ssl_certificate_key ...;
    
          location /docker-registry {
             proxy_pass http://localhost:5000/;
          }
       }
    }
    
    events { }
    

    但是执行docker push {domain}/docker-registry/hello-world时报错了,我应该怎么解决呢?

    报错信息如下:

    error parsing HTTP 404 response body: invalid character '<' looking for beginning of value: "<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.18.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n"
    

    如果我将 location /docker-registry 改为 location /,然后执行 docker push {domain}/hello-world,是可以成功的。

    4 replies    2021-04-28 10:43:52 +08:00
    hljjhb
        1
    hljjhb  
       Apr 27, 2021
    Docker 不支持,据我所知也没有 workaround
    oott123
        2
    oott123  
       Apr 28, 2021 via Android
    docker registry 不是这么工作的…它用到了很复杂的 api 。一楼说得对,基本上没有办法。
    ihipop
        3
    ihipop  
       Apr 28, 2021 via Android
    @hljjhb 方法
    1.用子域名
    2.记得 docker client 有特殊的 useragent 的,可以试试通过 UA 决定是 proxy pass 到后端 registery 还是正常服务网站
    no1xsyzy
        4
    no1xsyzy  
       Apr 28, 2021
    @ihipop 这是 solution
    但也不能添加(而是使你不需要) path 前缀
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5801 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 02:59 · PVG 10:59 · LAX 19:59 · JFK 22:59
    ♥ Do have faith in what you're doing.