8000 revamp the example of using the service as a Traefik middleware · reugn/auth-server@834bb08 · GitHub
[go: up one dir, main page]

Skip to content

Commit 834bb08

Browse files
committed
revamp the example of using the service as a Traefik middleware
1 parent d58ff3b commit 834bb08

File tree

7 files changed

+66
-60
lines changed

7 files changed

+66
-60
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# syntax=docker/dockerfile:1.2
12
FROM golang:alpine3.19 AS build
23
RUN apk --no-cache add gcc g++ make git
34
WORKDIR /go/src/app
@@ -13,5 +14,5 @@ COPY --from=build /go/src/app/config /app/
1314
COPY ./secrets ./secrets
1415
ENV AUTH_SERVER_LOCAL_CONFIG_PATH=local_repository_config.yml
1516

16-
EXPOSE 8080
17+
EXPOSE 8081
1718
ENTRYPOINT ["/app/auth", "-c", "service_config.yml"]

config/service_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
signing-method: RS256
3-
proxy: simple
3+
proxy: traefik
44
repository: local
55
http:
66
host: 0.0.0.0
7-
port: 8080
7+
port: 8081
88
rate:
99
tps: 1024
1010
size: 1024
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
version: '3.4'
22

3+
networks:
4+
proxy:
5+
36
services:
47
reverse-proxy:
58
restart: always
6-
image: traefik:v2.2
9+
image: traefik:v2.11
710
container_name: traefik
811
ports:
912
- 443:443
10-
- 8080:8080
1113
- 8082:8082
1214
volumes:
1315
- /var/run/docker.sock:/var/run/docker.sock
14-
- ./traefik.toml:/etc/traefik/traefik.toml
15-
- ./dynamic_conf.toml:/etc/traefik/dynamic_conf.toml
16+
- ./traefik.yml:/etc/traefik/traefik.yml
17+
- ./dynamic-config.yml:/etc/traefik/dynamic-config.yml
1618
labels:
19+
- "traefik.http.routers.site.entryPoints=http,websecure"
1720
- "traefik.enable=true"
21+
- "traefik.port=8082"
1822
networks:
1923
- proxy
2024

@@ -27,12 +31,5 @@ services:
2731
build:
2832
dockerfile: Dockerfile
2933
context: ../../.
30-
command: "-proxy=traefik -repo=local"
31-
labels:
32-
- "traefik.enable=true"
3334
networks:
3435
- proxy
35-
36-
networks:
37-
proxy:
38-
external: true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
http:
3+
services:
4+
auth-server:
5+
loadBalancer:
6+
servers:
7+
- url: http://auth-server:8081/
8+
9+
middlewares:
10+
test-auth:
11+
forwardAuth:
12+
address: http://auth-server:8081/auth
13+
authResponseHeaders:
14+
- "X-Auth-User"
15+
- "X-Secret"
16+
trustForwardHeader: true
17+
18+
routers:
19+
token-router:
20+
rule: "Path(`/token`)"
21+
service: auth-server
22+
entrypoints:
23+
- http
24+
priority: 2
25+
26+
auth-router:
27+
rule: "HostRegexp(`{host:.*}`)"
28+
middlewares:
29+
- test-auth
30+
service: auth-server
31+
entrypoints:
32+
- http
33+
priority: 1

examples/traefik/dynamic_conf.toml

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/traefik/traefik.toml

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/traefik/traefik.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
global:
3+
checkNewVersion: true
4+
sendAnonymousUsage: true
5+
6+
entryPoints:
7+
websecure:
8+
address: ":443"
9+
http:
10+
address: ":8082"
11+
12+
api:
13+
dashboard: true
14+
insecure: true
15+
16+
providers:
17+
file:
18+
filename: /etc/traefik/dynamic-config.yml
19+
watch: true
20+
docker:
21+
network: proxy

0 commit comments

Comments
 (0)
0