docker - 子域有效,但域不在 Traefik 路由器规则中
问题描述
我有一个在开发中使用的工作 traefik 文件配置。
使用下面的配置,当我 docker-compose up
可以访问主机时,api.contacts.localhost
但是当我尝试访问contacts.localhost
哪个为反应应用程序提供服务时,它没有,它会自动将其方案更改为https
backend:
build:
context: "./api"
target: dev
container_name: backend
environment:
- APP_PORT
- APP_HOSTNAME
- DB_USER
- DB_PASSWORD
- DB_HOST
env_file: ".env"
expose:
- 4000
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.backend.rule=Host(`api.contacts.localhost`)"
- "traefik.port=80"
volumes:
- "./api:/app"
depends_on:
- database
client:
build:
context: "./client"
target: dev
container_name: client
ports:
- "3000:3000"
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.client.rule=Host(`contacts.localhost`)"
- "traefik.port=80"
depends_on:
- backend
volumes:
- "./client:/app"
如果我将规则client
从更改contacts.localhost
为client.contacts.localhost
client:
...
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.client.rule=Host(`client.contacts.localhost`)"
- "traefik.port=80"
我现在可以访问我的反应应用程序。
有没有办法在不需要子域的情况下为我的反应应用程序提供服务?
解决方案
推荐阅读
- python - 如何在 scrapy 中使用 phnomatjs 或其他驱动程序设置动态代理和用户代理
- java - 多线程环境下ConcurrentHashMap的块读操作
- c# - Project Euler 549 - 我的函数没有返回它应该返回的答案,我不知道出了什么问题
- networking - ccTLD 和 gTLD 是否分层
- javascript - 从网页执行 Linux 命令
- c++ - 矩阵乘法速度取决于愚蠢的事情
- javascript - 存储首选主题的最佳方式?
- julia - Julia 中的 Convolution3d 实现
- ios - 如何在 UITabBarController 中使用 UINavigationController
- video - 禁止使用 Admob!奖励视频?