mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: use traefik to proxy in production
This commit is contained in:
1 parent
3c2dfcf322
commit
8161849504
2 files changed
+37
-43
No files matched your search
@@ -7,45 +7,4 @@ server {
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://backend:3000;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
location /trpc/ {
|
||||
proxy_pass http://backend:3000;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
location /api-docs/ {
|
||||
proxy_pass http://backend:3000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /socket.io/ {
|
||||
proxy_pass http://backend:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
proxy_buffering off;
|
||||
}
|
||||
}
|
||||
+37
-2
@@ -1,4 +1,20 @@
|
||||
services:
|
||||
traefik:
|
||||
image: traefik:v3.3
|
||||
ports:
|
||||
- 8000:8000
|
||||
- 8080:8080
|
||||
networks:
|
||||
- players
|
||||
- internal
|
||||
command:
|
||||
- '--api.insecure=true'
|
||||
- '--providers.docker=true'
|
||||
- '--providers.docker.exposedbydefault=false'
|
||||
- '--entrypoints.web.address=:8000'
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
app:
|
||||
image: linuxodyssey/frontend
|
||||
depends_on:
|
||||
@@ -10,8 +26,12 @@ services:
|
||||
target: prod
|
||||
networks:
|
||||
- internal
|
||||
ports:
|
||||
- 8080:80
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.app.entrypoints=web'
|
||||
- 'traefik.http.routers.app.rule=PathPrefix(`/`)'
|
||||
- 'traefik.http.routers.app.service=app'
|
||||
- 'traefik.http.services.app.loadbalancer.server.port=80'
|
||||
|
||||
backend:
|
||||
image: linuxodyssey/backend
|
||||
@@ -36,6 +56,21 @@ services:
|
||||
- DOCKER_NETWORK=linux-odyssey-players
|
||||
- BACKEND_URL=http://backend:3000
|
||||
- HOST_PROJECT_ROOT=${PWD}
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.backend-api.entrypoints=web'
|
||||
- 'traefik.http.routers.backend-api.rule=PathPrefix(`/api`)'
|
||||
- 'traefik.http.routers.backend-api.service=backend'
|
||||
- 'traefik.http.routers.backend-socket.entrypoints=web'
|
||||
- 'traefik.http.routers.backend-socket.rule=PathPrefix(`/socket.io`)'
|
||||
- 'traefik.http.routers.backend-socket.service=backend'
|
||||
- 'traefik.http.routers.backend-trpc.entrypoints=web'
|
||||
- 'traefik.http.routers.backend-trpc.rule=PathPrefix(`/trpc`)'
|
||||
- 'traefik.http.routers.backend-trpc.service=backend'
|
||||
- 'traefik.http.routers.backend-api-docs.entrypoints=web'
|
||||
- 'traefik.http.routers.backend-api-docs.rule=PathPrefix(`/api-docs`)'
|
||||
- 'traefik.http.routers.backend-api-docs.service=backend'
|
||||
- 'traefik.http.services.backend.loadbalancer.server.port=3000'
|
||||
|
||||
analytics:
|
||||
image: linuxodyssey/analytics
|
||||
|
||||
Reference in new issue
Block a user