我无法使用 nginx 作为 nexus 的反向代理服务器登录 docker
I can't login docker using nginx as reverse proxy server for nexus
我有使用 docker-compose 构建的环境。 Nexus 网站运行正常,但我无法使用 docker.
登录
这是我尝试登录时遇到的错误
C:\Users\j0nl1>docker login repository.localhost
Username: admin
Password:
Error response from daemon: Get
http://repository.localhost/v2/: dial tcp: lookup
repository.localhost on 192.168.65.1:53: no such host
我的 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-编写文件:
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
我有使用 docker-compose 构建的环境。 Nexus 网站运行正常,但我无法使用 docker.
登录这是我尝试登录时遇到的错误
C:\Users\j0nl1>docker login repository.localhost
Username: admin
Password:
Error response from daemon: Get http://repository.localhost/v2/: dial tcp: lookup repository.localhost on 192.168.65.1:53: no such host
我的 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-编写文件:
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