docker 中安装traefik 可以参考这篇文章
https://q.shanyue.tech/deploy/traefik.html#traefik-%E6%90%AD%E5%BB%BA
docker-compose.yaml 文件配置
version: '3.3'networks: traefik: external: true
services: main: container_name: main image: hello:v1 working_dir: /hello ports: - "3002:3002" restart: always labels: - "traefik.enable=true" - "traefik.http.routers.hello.service=hello" - "traefik.http.services.hello.loadbalancer.server.port=3002" # Host()中填写ip 就可以通过ip进行访问,填写域名就通过域名进行访问 # PathPrefix url请求前缀 - "traefik.http.routers.hello.rule=Host(`xxx.xxx.xxx`) && PathPrefix(`/hello`)" - "traefik.http.routers.hello.middlewares=hello-stripprefix" - "traefik.http.middlewares.hello-stripprefix.stripprefix.prefixes=/hello" # networks 必须和traefik 使用同一个,不然服务启动后,traefik无法发现 networks: - traefik
标签:http,traefik,3002,hello,routers,networks From: https://www.cnblogs.com/nothingness/p/16803879.html