Nginx Plus 无法使用 Docker 嵌入式 DNS 服务器解析服务
Nginx Plus fails to resolve service using Docker embedded DNS server
我在 windows 10 上的 docker 集群模式下有一个 nginxplus 容器和一个演示服务 运行。
我将端点模式用作演示服务的 dnsrr,以便 nginx 可以使用 docker DNS 服务器作为演示服务的解析器。
但是我在 nginxplus 日志中收到一条错误消息 "service http of demosvcalias could not be resolved (3: Host not found)"
Docker resolv.conf 将 127.0.0.11 显示为看起来正确的名称服务器。
**docker exec -it b7665155d8e0 cat /etc/resolv.conf**
search xxx.com dev.xxx.com
nameserver 127.0.0.11
options ndots:0
docker-撰写演示服务
version: "3.3"
services:
demosvc:
image: demo:latest
deploy:
endpoint_mode: dnsrr
replicas: 1
resources:
limits:
cpus: "0.1"
memory: 5000M
restart_policy:
condition: on-failure
#ports:
#- "8081:8080"
networks:
my-swarm-network :
aliases:
- demosvcalias
networks:
my-swarm-network:
external: true
docker-compose for nginx plus
version: "3"
services:
nginxp:
image: nginxp:latest
deploy:
replicas: 1
resources:
limits:
cpus: "0.1"
memory: 5000M
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- my-swarm-network
networks:
my-swarm-network:
external: true
nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
resolver 127.0.0.11 valid=60s ipv6=off;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html;
}
location /demo {
proxy_pass http://demobackend;
}
}
upstream demobackend {
zone backend 32k;
server demosvcalias service=http resolve;
}
}
我还可以使用 docker exec 实用程序从 nginx 容器中卷曲 http://demosvscalias:8080/demo.html。但是 nginx 解析器无法使用 Docker 嵌入式 DNS 服务器 (127.0.0.11) 解析 demosvc。
我在这里遗漏了什么吗?
更新:
在以下更新后,负载平衡在 docker 嵌入式 DNS 服务器作为解析器时工作正常。
在nginx.conf
server demosvcalias service=http resolve ==> server demosvcalias:8080 resolve;
已更新nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
resolver 127.0.0.11 valid=60s ipv6=off;
resolver_timeout 10s;
server {
access_log /var/log/nginx/access.log upstreamlog;
listen 80;
server_name localhost;
location / {
root html;
index index.html;
}
location /demo {
proxy_pass http://demobackend;
}
}
upstream demobackend {
zone backend 32k;
server demosvcalias:8080 resolve;
}
}
以下更新后,负载平衡在 docker 嵌入式 DNS 服务器作为解析器时工作正常。
在nginx.conf
server demosvcalias service=http resolve ==> server demosvcalias:8080 resolve;
已更新nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
resolver 127.0.0.11 valid=60s ipv6=off;
resolver_timeout 10s;
server {
access_log /var/log/nginx/access.log upstreamlog;
listen 80;
server_name localhost;
location / {
root html;
index index.html;
}
location /demo {
proxy_pass http://demobackend;
}
}
upstream demobackend {
zone backend 32k;
server demosvcalias:8080 resolve;
}
}
我将不得不详细了解 service=http 导致问题的原因。不确定是由于我使用的 Nginxplus 版本还是其他原因。如果我发现任何东西会更新
我在 windows 10 上的 docker 集群模式下有一个 nginxplus 容器和一个演示服务 运行。
我将端点模式用作演示服务的 dnsrr,以便 nginx 可以使用 docker DNS 服务器作为演示服务的解析器。
但是我在 nginxplus 日志中收到一条错误消息 "service http of demosvcalias could not be resolved (3: Host not found)"
Docker resolv.conf 将 127.0.0.11 显示为看起来正确的名称服务器。
**docker exec -it b7665155d8e0 cat /etc/resolv.conf**
search xxx.com dev.xxx.com
nameserver 127.0.0.11
options ndots:0
docker-撰写演示服务
version: "3.3"
services:
demosvc:
image: demo:latest
deploy:
endpoint_mode: dnsrr
replicas: 1
resources:
limits:
cpus: "0.1"
memory: 5000M
restart_policy:
condition: on-failure
#ports:
#- "8081:8080"
networks:
my-swarm-network :
aliases:
- demosvcalias
networks:
my-swarm-network:
external: true
docker-compose for nginx plus
version: "3"
services:
nginxp:
image: nginxp:latest
deploy:
replicas: 1
resources:
limits:
cpus: "0.1"
memory: 5000M
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- my-swarm-network
networks:
my-swarm-network:
external: true
nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
resolver 127.0.0.11 valid=60s ipv6=off;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html;
}
location /demo {
proxy_pass http://demobackend;
}
}
upstream demobackend {
zone backend 32k;
server demosvcalias service=http resolve;
}
}
我还可以使用 docker exec 实用程序从 nginx 容器中卷曲 http://demosvscalias:8080/demo.html。但是 nginx 解析器无法使用 Docker 嵌入式 DNS 服务器 (127.0.0.11) 解析 demosvc。
我在这里遗漏了什么吗?
更新: 在以下更新后,负载平衡在 docker 嵌入式 DNS 服务器作为解析器时工作正常。
在nginx.conf
server demosvcalias service=http resolve ==> server demosvcalias:8080 resolve;
已更新nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
resolver 127.0.0.11 valid=60s ipv6=off;
resolver_timeout 10s;
server {
access_log /var/log/nginx/access.log upstreamlog;
listen 80;
server_name localhost;
location / {
root html;
index index.html;
}
location /demo {
proxy_pass http://demobackend;
}
}
upstream demobackend {
zone backend 32k;
server demosvcalias:8080 resolve;
}
}
以下更新后,负载平衡在 docker 嵌入式 DNS 服务器作为解析器时工作正常。
在nginx.conf
server demosvcalias service=http resolve ==> server demosvcalias:8080 resolve;
已更新nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
resolver 127.0.0.11 valid=60s ipv6=off;
resolver_timeout 10s;
server {
access_log /var/log/nginx/access.log upstreamlog;
listen 80;
server_name localhost;
location / {
root html;
index index.html;
}
location /demo {
proxy_pass http://demobackend;
}
}
upstream demobackend {
zone backend 32k;
server demosvcalias:8080 resolve;
}
}
我将不得不详细了解 service=http 导致问题的原因。不确定是由于我使用的 Nginxplus 版本还是其他原因。如果我发现任何东西会更新