[英]docker(-compose): access wikijs container only through nginx-proxy-manager; 502 Bad Gateway
I'm running a server that I want to setup to provide several webservices.我正在运行一个服务器,我想将其设置为提供多个网络服务。 One service is WikiJS.
一项服务是 WikiJS。
I want the service to only be accessible through nginx-proxy-manager via a subdomain, but not directly accessing the IP (and port) of the server.我希望该服务只能通过子域通过 nginx-proxy-manager 访问,但不能直接访问服务器的 IP(和端口)。
My try was:我的尝试是:
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
In nginx-proxy-manager I then tried to use "wikijs" as the forwarding host.在 nginx-proxy-manager 中,我尝试使用“wikijs”作为转发主机。
The service is accessible if I try: http://publicip:3001, however not via the assigned subdomain in nginx-proxy-manager.如果我尝试访问该服务:http://publicip:3001,但不能通过 nginx-proxy-manager 中指定的子域访问。 I only get a 502 which usually means, that nginx-proxy-manager cannot access the given service.
我只得到一个 502,这通常意味着 nginx-proxy-manager 无法访问给定的服务。
What do I have to change to make the service available unter the domain but not from http://publicip:3001?我必须更改什么才能使服务在域下可用,但不能从 http://publicip:3001 获取?
Thanks in advance.提前致谢。
Ok, I finally found out what my conceptual problem was: I needed to create a.network bridge for the two containers.好的,我终于发现了我的概念性问题:我需要为两个容器创建一个 .network 桥。 Basically it was as basic as specifying the driver of the.network:
基本上它就像指定.network 的驱动程序一样基本:
networks:
reverseproxy-nw:
driver: bridge
Like this the wikijs-container is only available through nginx as I want it to be.像这样,wikijs-container 只能通过 nginx 获得,正如我希望的那样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.