我试图在 Google Compute VM 上设置 nginx 代理。所以我希望我的域名 (www.example.com) 转到正确的容器。但是由于某种原因,它只有在我将端口号放在地址栏中(www.example.com:3001)时才有效,这完全违背了目的。
谁能让我知道我做错了什么??
nginx-proxy docker-compose.yml
version: '3'
services:
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- 80:80
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- backend
networks:
backend:
driver: bridge
应用程序 docker-compose.yml
version: '3'
services:
api:
image: api-image:latest
build:
context: ./
dockerfile: Dockerfile
ports:
- 3000:8080
networks:
- backend
public:
image: app-image:latest
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- 3001:8081
networks:
- backend
environment:
- VIRTUAL_HOST=www.example.com
- VIRTUAL_PORT=3001
networks:
backend:
driver: bridge
public
因此,当我放置 www.example.com:3001 时,上述内容正确地代理了容器。
想法??谢谢!