Skip to content

Instantly share code, notes, and snippets.

@brunocascio
Last active October 6, 2023 16:42
Show Gist options
  • Save brunocascio/7136080b24d2a9dabe98530af2d589bf to your computer and use it in GitHub Desktop.
Save brunocascio/7136080b24d2a9dabe98530af2d589bf to your computer and use it in GitHub Desktop.
Traefik fix 502 for empty backends
version: "3.8"
networks:
traefik:
services:
traefik:
image: traefik:v2.4
networks:
- traefik
ports:
- "80:80/tcp" # http entrypoint
- "8080:8080/tcp" # Traefik Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock # needed for service discovery
environment:
- "TRAEFIK_API_INSECURE=true"
- "TRAEFIK_API_DASHBOARD=true"
- "TRAEFIK_PROVIDERS_DOCKER=true"
- "TRAEFIK_PROVIDERS_DOCKER_EXPOSEDBYDEFAULT=false"
- "TRAEFIK_PROVIDERS_DOCKER_SWARMMODE=true"
- "TRAEFIK_ENTRYPOINTS_HTTP=true"
- "TRAEFIK_ENTRYPOINTS_HTTP_ADDRESS=:80"
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik-502.entrypoints=http"
- "traefik.http.routers.traefik-502.rule=PathPrefix(`/`)"
- "traefik.http.routers.traefik-502.priority=1"
- "traefik.http.services.traefik-502.loadbalancer.server.port=0"
static-app:
image: valian/nginx-test-page
networks:
- traefik
deploy:
replicas: 2
labels:
- "traefik.enable=true"
- "traefik.http.routers.static-app.entrypoints=http"
- "traefik.http.routers.static-app.rule=Host(`static-app.127.0.0.1.sslip.io`)"
- "traefik.http.services.static-app.loadbalancer.server.port=80"
- "traefik.docker.network=traefik"
another-app:
image: nginx:alpine
networks:
- traefik
deploy:
replicas: 1
labels:
- "traefik.enable=true"
- "traefik.http.routers.another-app.entrypoints=http"
- "traefik.http.routers.another-app.rule=Host(`another-app.127.0.0.1.sslip.io`)"
- "traefik.http.services.another-app.loadbalancer.server.port=80"
- "traefik.docker.network=traefik"
@jackgray
Copy link

jackgray commented Oct 6, 2023

After all this, it still doesn't seem possible to use Traefik with only a local IP address without a special DNS server or modified system files.

Every other proxy solution I have used I can simply add my machine's IP address. You should not be required to complicate your solution unnecessarily to use the core functionality of this product. I work in a small team under a major institute and can't edit their DNS server. I also am not interested in worrying about maintaining individual machine's system files.

If you are saying that this is possible, can we have an example please? I want to type http://remote-machine-ip-addr/docker-service into my web browser. I feel like the documentation does not cover local development or deployment very well. You must go straight into the public hosting realm to have a minimally viable product.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment