nginx-proxy 不适用于 swagger-ui docker container 502 Bad Gateway
nginx-proxy doesn't work with swagger-ui docker container 502 Bad Gateway
我想将本地网址从 'localhost:port' 更改为项目相关网址。堆栈中的每个其他容器(节点服务器等)都可以工作,但只有 swagger 容器给出错误 502 Bad Gateway。
我将其添加到我的 /etc/hosts 文件中:
127.0.0.1 my-api-doc.local
这是我的 docker-compose.yml 文件:
version: '3'
services:
api_doc:
image: swaggerapi/swagger-ui
environment:
- "VIRTUAL_HOST=my-api-doc.local"
- "VIRTUAL_PORT=4000"
ports:
- "4000:8080"
links:
- nginx-proxy
nginx-proxy:
image: jwilder/nginx-proxy:alpine
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
restart: unless-stopped
问题是,当我在浏览器中转到 'my-api-doc.local' 时,我收到“502 Bad Gateway”错误。当我尝试 'localhost:4000' 时,它起作用了。
我将 nginx 管理器更改为 'traefik' docker 映像。那个固定的问题对我来说。我的最终 docker 撰写文件如下:
version: '3'
services:
apiDoc:
image: swaggerapi/swagger-ui
container_name: "linkit_api_doc"
volumes:
- ../../src/server/:/usr/app/
depends_on:
- server
labels:
- "traefik.frontend.rule=Host:linkit-air-api.local"
- "traefik.port=8080"
reverse-proxy:
image: traefik # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Træfik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
我想将本地网址从 'localhost:port' 更改为项目相关网址。堆栈中的每个其他容器(节点服务器等)都可以工作,但只有 swagger 容器给出错误 502 Bad Gateway。
我将其添加到我的 /etc/hosts 文件中:
127.0.0.1 my-api-doc.local
这是我的 docker-compose.yml 文件:
version: '3'
services:
api_doc:
image: swaggerapi/swagger-ui
environment:
- "VIRTUAL_HOST=my-api-doc.local"
- "VIRTUAL_PORT=4000"
ports:
- "4000:8080"
links:
- nginx-proxy
nginx-proxy:
image: jwilder/nginx-proxy:alpine
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
restart: unless-stopped
问题是,当我在浏览器中转到 'my-api-doc.local' 时,我收到“502 Bad Gateway”错误。当我尝试 'localhost:4000' 时,它起作用了。
我将 nginx 管理器更改为 'traefik' docker 映像。那个固定的问题对我来说。我的最终 docker 撰写文件如下:
version: '3'
services:
apiDoc:
image: swaggerapi/swagger-ui
container_name: "linkit_api_doc"
volumes:
- ../../src/server/:/usr/app/
depends_on:
- server
labels:
- "traefik.frontend.rule=Host:linkit-air-api.local"
- "traefik.port=8080"
reverse-proxy:
image: traefik # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Træfik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events