Docker :仅通过nginx-proxy-manager访问维基容器; 502网关错误

qxsslcnc  于 2022-12-03  发布在  Nginx
关注(0)|答案(1)|浏览(139)

我正在运行一个服务器,我想设置它来提供几个Web服务。其中一个服务是WikiJS。
我希望服务只能通过nginx-proxy-manager通过子域访问,而不能直接访问服务器的IP(和端口)。
我的尝试是:

version: "3"



services:
  nginxproxymanager:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '8181:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP

    # Uncomment the next line if you uncomment anything in the section
    # environment:
      # Uncomment this if you want to change the location of
      # the SQLite DB file within the container
      # DB_SQLITE_FILE: "/data/database.sqlite"

      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'

    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    networks:
      - reverseproxy-nw

  db:
    image: postgres:11-alpine
    environment:
      POSTGRES_DB: wiki
      POSTGRES_PASSWORD: ###DBPW
      POSTGRES_USER: wikijs
    logging:
      driver: "none"
    restart: unless-stopped
    volumes:
      - db-data:/var/lib/postgresql/data
    networks:
      - reverseproxy-nw

  wiki:
    image: requarks/wiki:2
    depends_on:
      - db
    environment:
      DB_TYPE: postgres
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: wikijs
      DB_PASS: ###DBPW
      DB_NAME: wiki
    restart: unless-stopped
    ports:
      - "3001:3000"
    networks:
      - reverseproxy-nw

volumes:
  db-data:

networks:
  reverseproxy-nw:
    external: true

在nginx-proxy-manager中,我尝试使用“wikijs”作为转发主机。x1c 0d1x
如果我尝试以下操作,则可以访问该服务:http://publicip:3001,但不是通过nginx-proxy-manager中指定的子域。我只得到一个502,这通常意味着nginx-proxy-manager不能访问给定的服务。
要使服务在域中可用,而不是在http://publicip:3001中可用,我需要做哪些更改?
先谢谢你。

muk1a3rh

muk1a3rh1#

好了,我终于发现我的概念问题是什么了:我需要为两个容器创建一个网桥,基本上就像指定网络的驱动程序一样简单:

networks:
  reverseproxy-nw:
    driver: bridge

像这样的wikijs-container只能通过nginx使用,正如我所希望的那样。

相关问题