繁体   English   中英

我无法使用Nginx作为Nexus的反向代理服务器登录Docker

[英]I can't login docker using nginx as reverse proxy server for nexus

我已经用docker-compose构建了环境。 Nexus网站运行正常,但无法登录docker。

这是我尝试登录时遇到的错误

C:\\ Users \\ j0nl1> docker登录存储库.localhost

用户名:admin

密码:

来自守护程序的错误响应:获取http://repository.localhost/v2/ :拨打tcp:查找192.168.65.1:53上的repository.localhost:没有这样的主机

我的default.conf文件:

worker_processes 2;

events { 
    worker_connections 1024; 
}

http {
    error_log /var/log/nginx/error.log warn;
    access_log  /dev/null;
    proxy_intercept_errors off;
    proxy_send_timeout 120;
    proxy_read_timeout 300;

    server {
    listen 80;
    location / {
        proxy_pass http://web:3000;
    }
}

    upstream nexus {
        server nexus:8081;
    }

    upstream registry {
        server nexus:8082;
    }

    server {
        listen 80;
        server_name repository.localhost;

        keepalive_timeout  5 5;
        proxy_buffering    off;

        # allow large uploads
        client_max_body_size 1G;

        location / {
        # redirect to docker registry
        if ($http_user_agent ~ docker ) {
            proxy_pass http://registry;
        }
        proxy_pass http://nexus;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
}

docker-compose文件:

version: '3'
services:
  web:
    build: './web'
    ports:
      - "3000:3000"

  nexus:
    build: './nexus'
    ports:
      - "8081:8081"
      - "8082:8082"
      - "8083:8083"
    volumes:
      - c:/docker/nexus:/nexus-data

  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./default.conf:/etc/nginx/nginx.conf
    depends_on:
      - web
      - nexus

Nexus DockerFile:

FROM sonatype/nexus3:3.17.0

EXPOSE 8081-8083

将此添加到您的主机文件

127.0.0.1 repository.localhost

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM