I would like to change my local urls from 'localhost:port' to project related urls. Every other container in the stack (Node server etc.) works but only swagger container gives error 502 Bad Gateway.
I add this to my /etc/hosts file:
127.0.0.1 my-api-doc.local
here is my docker-compose.yml file:
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
Problem is, when i go to 'my-api-doc.local' in my browser, i receive '502 Bad Gateway' error. When i try 'localhost:4000', it works.
I change nginx manager to 'traefik' docker image. That fixed problem for me. My final docker compose file is following:
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