请协助。
我发现了一篇博客文章,https: //blog.ssdnodes.com/blog/host-multiple-ssl-websites-docker-nginx/)关于部署多个 docker-compose 应用程序具有相同nginx-proxy
但具有不同的VIRTUAL_HOST
名称
但由于某种原因,两个应用程序都返回错误 502 Bad Gateway
以下错误是我运行时看到的docker-compose logs nginx
2019/05/29 20:52:26 [error] 8#8: *15 connect() failed (111: Connection refused) while connecting to upstream, client: 52.209.30.187, server: gregsithole.com, request: "GET / HTTP/1.1", upstream: "http://172.20.0.5:80/", host: "gregsithole.com"
而且我相信upstream
使用的是内部 docker 网络 IP,因为那不是我的服务器的 IP。我的上游由以下文件确定:https ://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl
但我不太熟悉它是如何工作的。
以下是我的 docker-compose 文件的示例:
nginx-proxy/docker-compose.yaml
version: "3.6"
services:
nginx:
image: nginx
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- conf:/etc/nginx/conf.d
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- certs:/etc/nginx/certs
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
dockergen:
image: jwilder/docker-gen
container_name: nginx-proxy-gen
restart: always
depends_on:
- nginx
command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
volumes:
- conf:/etc/nginx/conf.d
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- certs:/etc/nginx/certs
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-proxy-le
restart: always
depends_on:
- nginx
- dockergen
environment:
NGINX_PROXY_CONTAINER: nginx-proxy
NGINX_DOCKER_GEN_CONTAINER: nginx-proxy-gen
volumes:
- conf:/etc/nginx/conf.d
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- certs:/etc/nginx/certs
- /var/run/docker.sock:/var/run/docker.sock:ro
volumes:
conf:
vhost:
html:
certs:
networks:
default:
external:
name: nginx-proxy
dockerized-ghost/docker-compose.yaml
version: "3.6"
services:
ghost:
image: ghost
restart: always
expose:
- 80
volumes:
- ../../ghost:/var/lib/ghost/content
environment:
NODE_ENV: production
url: https://blog.gregsithole.com
VIRTUAL_HOST: blog.gregsithole.com
LETSENCRYPT_HOST: blog.gregsithole.com
LETSENCRYPT_EMAIL: hidden-email
networks:
default:
external:
name: nginx-proxy
请协助