Created
May 14, 2021 03:49
-
-
Save valorad/7590048475555051a058a3e08199d83a to your computer and use it in GitHub Desktop.
traefik docker redirect statics example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
version: "3.9" | |
services: | |
node: | |
labels: | |
- "traefik.enable=true" | |
# Vue Dev Server | |
- "traefik.http.routers.runvuedev.rule=Host(`runvuedev.code.hub`)" | |
- "traefik.http.routers.runvuedev.entrypoints=websecure" | |
- "traefik.http.routers.runvuedev.tls=true" | |
- "traefik.http.routers.runvuedev.service=runvuedev" | |
- "traefik.http.services.runvuedev.loadbalancer.server.port=8080" | |
# Backend Koa Server - Statics | |
- "traefik.http.routers.runnode.rule=Host(`runnode.code.hub`)" | |
- "traefik.http.routers.runnode.entrypoints=websecure" | |
- "traefik.http.routers.runnode.tls=true" | |
- "traefik.http.routers.runnode.middlewares=feRedirect" | |
- "traefik.http.routers.runnode.service=runnode" | |
- "traefik.http.services.runnode.loadbalancer.server.port=3000" | |
# front-end Redirect static | |
- "traefik.http.middlewares.feRedirect.redirectregex.regex=https://(.+?/)(.*)" | |
- "traefik.http.middlewares.feRedirect.redirectregex.replacement=https://statics.drive.hub/fe-bucket/$$2" | |
# Backend Koa Server | |
- "traefik.http.routers.runnodeAPI.rule=(Host(`runnode.code.hub`) && PathPrefix(`/api`))" | |
- "traefik.http.routers.runnodeAPI.tls=true" | |
- "traefik.http.routers.runnodeAPI.entrypoints=websecure" | |
- "traefik.http.routers.runnodeAPI.service=runnodeAPI" | |
- "traefik.http.services.runnodeAPI.loadbalancer.server.port=3000" | |
image: node:current-buster | |
restart: "no" | |
user: "1000" | |
stdin_open: true | |
tty: true | |
volumes: | |
- /workspace/workbench:/workspace/workbench | |
networks: | |
- main | |
networks: | |
main: | |
external: | |
name: main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Objective:
https://runnode.code.hub/ ==> https://statics.drive.hub/fe-bucket/
https://runnode.code.hub/statics/images/cat.png ==> https://statics.drive.hub/fe-bucket/statics/images/cat.png
https://runnode.code.hub/api =xx (No redirect)