我正在使用 traefik 和 docker compose 設(shè)置前端和后端,如下所示:version: "3.7"services: frontend: image: frontend:tag networks: - traefik-network labels: - traefik.enable=true - traefik.port=80 - traefik.docker.network=traefik-network - traefik.http.routers.frontend.entrypoints=web - traefik.http.routers.frontend.rule=PathPrefix(`/`) backend: image: backend:tag networks: - traefik-network labels: - traefik.enable=true - traefik.port=3000 - traefik.docker.network=traefik-networkreverse-proxy: image: traefik:v2.0 networks: - traefik-network labels: - traefik.docker.network=traefik-network - traefik.enable=true command: - --log.level=DEBUG - --api.insecure=true - --providers.docker=true - --providers.docker.exposedbydefault=false - --entryPoints.web.address=:80 - --entryPoints.name.forwardedHeaders.insecure=true ports: - "80:80" - "3000:3000" - "8080:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock:ronetworks: traefik-network: name: traefik-network之前我使用 nginx 創(chuàng)建從 FE 到 BE 的代理,如下所示upstream go_backend { server backend:8085 max_fails=3 fail_timeout=50;}location /api/ { proxy_pass http://go_backend/;}我如何使用 traefik v2 將請(qǐng)求從 FE 代理到 BE?沒(méi)有 toml 文件。您期望什么結(jié)果:當(dāng)我轉(zhuǎn)到本地主機(jī)時(shí),來(lái)自服務(wù)器的請(qǐng)求被轉(zhuǎn)發(fā)到后端:3000?,F(xiàn)在發(fā)生了什么:當(dāng)我轉(zhuǎn)到本地主機(jī)時(shí),請(qǐng)求未到達(dá)后端。
1 回答

白豬掌柜的
TA貢獻(xiàn)1893條經(jīng)驗(yàn) 獲得超10個(gè)贊
對(duì)于處于相同位置的任何人:
- traefik.docker.network=traefik-network - traefik.http.routers.backend.entrypoints=backend
請(qǐng)記住設(shè)置您的服務(wù)的入口點(diǎn):- traefik.http.routers.<s-name>.entrypoints=<s-name>
- 1 回答
- 0 關(guān)注
- 155 瀏覽
添加回答
舉報(bào)
0/150
提交
取消