首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在同一主机上运行前向代理容器和DNS服务器容器时出现问题

在同一主机上运行前向代理容器和DNS服务器容器时出现问题
EN

Server Fault用户
提问于 2018-10-07 05:59:07
回答 2查看 516关注 0票数 1

这是一个在同一个主机上运行的Docker、pi-孔(容器)和worm孔代理(容器)的家庭实验。我的对接主机操作系统是RHEL 7.x。

我最初的目的是学习更多关于π孔的知识,因此我将服务作为容器托管在VMWare ESXI中的VM上。在我的一些Linux上,我可以通过编辑/etc/resolv.conf文件指向pi-孔来使用pi-hole作为DNS服务器。那里一切都很好。

因此,当我想在我的物理主桌面(Windows 10)上测试它时,我想我不需要通过来更改DNS服务器,我可以将一个前向代理服务器(Wormhole)容器与π-孔容器一起托管在同一个码头主机上。然后,我可以简单地告诉前向代理服务器使用pi-hole作为DNS服务器。

当前向代理服务器使用π洞作为DNS服务器时会出现问题.我将在前向代理服务器日志中看到以下错误消息。

代码语言:javascript
复制
wormhole_1_e0b4b0824de0 | 2018-10-07 05:32:28,528 wormhole[5]: [691dd8][192.168.20.40]: CONNECT 502 incoming.telemetry.mozilla.org:443 (gaierror: -3 Try again)
wormhole_1_e0b4b0824de0 | 2018-10-07 05:32:28,692 wormhole[5]: [643358][192.168.20.40]: CONNECT 502 incoming.telemetry.mozilla.org:443 (gaierror: -3 Try again)
wormhole_1_e0b4b0824de0 | 2018-10-07 05:32:28,693 wormhole[5]: [654eb8][192.168.20.40]: CONNECT 502 incoming.telemetry.mozilla.org:443 (gaierror: -3 Try again)

当在同一个码头主机上托管前向代理服务器容器和π孔容器时,如果我不显式地告诉代理服务器使用pi-孔作为DNS,那么它就可以正常工作了。如果我将前向代理服务器容器托管在不同的VM上,然后指定代理服务器使用pi-孔作为DNS服务器,那么它也可以正常工作。这使我相信存在着一些形式的冲突,但我不确定会发生什么,因为他们没有分享任何港口。

为了简单地复制我的问题,下面是我使用的docker-compose.ymls。

下面是虫洞代理(前向代理)服务器的docker-compose.ymldns:正在指向码头主机。

代码语言:javascript
复制
version: "3"
services:
  wormhole:
    image: bashell/wormhole:latest
    ports:
      - "8888:8800/tcp"
      - "8888:8800/udp"
    environment:
      TZ: "America/New_York"
    restart: always
    dns:
      - 192.168.10.120

下面是圆孔的docker-compose.yml。您需要更改卷的主机挂载点。

代码语言:javascript
复制
version: "3"
services:
  pihole:
    image: pihole/pihole:v4.0_amd64
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      # enter your docker host IP here
      ServerIP: 192.168.10.120
      # IPv6 Address if your network supports it
      # ServerIPv6:
      # jwilder/proxy envs, see readme for more info
      PROXY_LOCATION: pihole
      VIRTUAL_HOST: pihole.local
      VIRTUAL_PORT: 80
      TZ: "America/New_York"
      DNS1: 208.67.222.222
      DNS2: 1.1.1.1
      WEBPASSWORD: stackexchange
    # Add your own custom hostnames you need for your domain
    # extra_hosts:
      #   Point any of the jwilder virtual_host addresses
      # to your docker host ip address
      # - 'pihole.yourdomain.local:192.168.1.55'
    volumes:
      - '/Development/Applications/pi-hole/volumes/pihole/:/etc/pihole/:z'
      # WARNING: if this log don't exist as a file on the host already
      # docker will try to create a directory in it's place making for lots of errors
      - '/Development/Applications/pi-hole/volumes/log/pihole.log:/var/log/pihole.log:z'
      - '/Development/Applications/pi-hole/volumes/dnsmasq.d:/etc/dnsmasq.d:z'
    restart: always
EN

回答 2

Server Fault用户

回答已采纳

发布于 2018-10-07 21:59:03

我没有让前向代理服务器指向Docker主机作为DNS服务器,而是确保前向代理服务器和DNS服务器都驻留在同一个Docker网络上,并让前向代理服务器指向Docker分配的DNS服务器IP地址。

下面是前向代理服务器的docker-compose.yml

代码语言:javascript
复制
version: "3"
services:
  wormhole:
    image: bashell/wormhole:latest
    ports:
      - "8888:8800/tcp"
      - "8888:8800/udp"
    environment:
      TZ: "America/New_York"
    restart: always
    dns:
      - 172.20.0.99
    networks:
      - beyonddc
networks:
    beyonddc:
      external: true

下面是我的DNS服务器的docker-compose.yml

代码语言:javascript
复制
version: "3.5"
services:
  pihole:
    image: pihole/pihole:v4.0_amd64
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    networks:
       beyonddc:
         ipv4_address: 172.20.0.99
    environment:
      # enter your docker host IP here
      ServerIP: 192.168.10.120
      # IPv6 Address if your network supports it
      ServerIPv6: 2601:189:4200:eb2:250:56ff:febf:d245
      # jwilder/proxy envs, see readme for more info
      PROXY_LOCATION: pihole
      VIRTUAL_HOST: pihole.local
      VIRTUAL_PORT: 80
      TZ: "America/New_York"
      DNS1: 208.67.222.222
      DNS2: 1.1.1.1
      WEBPASSWORD: stackexchange
    # Add your own custom hostnames you need for your domain
    # extra_hosts:
      #   Point any of the jwilder virtual_host addresses
      # to your docker host ip address
      # - 'pihole.yourdomain.local:192.168.1.55'
    volumes:
      - '/Development/Applications/pi-hole/volumes/pihole/:/etc/pihole/:z'
      # WARNING: if this log don't exist as a file on the host already
      # docker will try to create a directory in it's place making for lots of errors
      - '/Development/Applications/pi-hole/volumes/log/pihole.log:/var/log/pihole.log:z'
      - '/Development/Applications/pi-hole/volumes/dnsmasq.d:/etc/dnsmasq.d:z'
    restart: always
networks:
  beyonddc:
    driver: bridge
    # Must specify the name for the network again otherwise by default
    # Docker will use the folder name as prefix of the network.
    # The name field is only available in version 3.5 and beyond
    name: beyonddc
    ipam:
      config:
        - subnet: 172.20.0.0/16
票数 0
EN

Server Fault用户

发布于 2018-10-07 07:30:05

我建议将这两个docker-compose.yml文件合并为一个:

代码语言:javascript
复制
version: "3"
services:
  wormhole:
    image: bashell/wormhole:latest
    link: pihole:dns.local
    ports:
      - "8888:8800/tcp"
      - "8888:8800/udp"
    environment:
      TZ: "America/New_York"
    restart: always
    dns:
      - dns.local
  pihole:
    image: pihole/pihole:v4.0_amd64
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      # enter your docker host IP here
      ServerIP: 192.168.10.120
      # IPv6 Address if your network supports it
      # ServerIPv6:
      # jwilder/proxy envs, see readme for more info
      PROXY_LOCATION: pihole
      VIRTUAL_HOST: pihole.local
      VIRTUAL_PORT: 80
      TZ: "America/New_York"
      DNS1: 208.67.222.222
      DNS2: 1.1.1.1
      WEBPASSWORD: stackexchange
    # Add your own custom hostnames you need for your domain
    # extra_hosts:
      #   Point any of the jwilder virtual_host addresses
      # to your docker host ip address
      # - 'pihole.yourdomain.local:192.168.1.55'
    volumes:
      - '/Development/Applications/pi-hole/volumes/pihole/:/etc/pihole/:z'
      # WARNING: if this log don't exist as a file on the host already
      # docker will try to create a directory in it's place making for lots of errors
      - '/Development/Applications/pi-hole/volumes/log/pihole.log:/var/log/pihole.log:z'
      - '/Development/Applications/pi-hole/volumes/dnsmasq.d:/etc/dnsmasq.d:z'
    restart: always

这样做可以自动地将两个容器添加到同一个码头网络中,并允许连接容器(请参阅上面的虫洞服务,其中我将dns.local指定为Pi孔容器的主机名,但仅限于虫洞容器的作用域)。这句话说得通吗?)

票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/934328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档