Skip to content

Commit 13e1002

Browse files
authored
Fix network policy and request forwarding (#31)
1 parent 6e26131 commit 13e1002

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

charts/azdo-proxy/templates/networkpolicy.yaml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,43 @@
22
apiVersion: networking.k8s.io/v1
33
kind: NetworkPolicy
44
metadata:
5-
name: {{ include "azdo-proxy.fullname" . }}-deny-ingress
5+
name: {{ include "azdo-proxy.fullname" . }}
66
labels:
77
{{- include "azdo-proxy.labels" . | nindent 4 }}
88
spec:
9+
podSelector:
10+
matchLabels:
11+
{{- include "azdo-proxy.labels" . | nindent 6 }}
912
policyTypes:
1013
- Ingress
1114
- Egress
1215
ingress:
13-
- from:
14-
- podSelector: {}
16+
- from:
17+
- podSelector:
18+
matchLabels:
19+
app: source-controller
20+
ports:
21+
- port: 8080
22+
- from:
23+
- namespaceSelector:
24+
matchLabels:
25+
name: prometheus
26+
ports:
27+
- port: 9090
1528
egress:
16-
- {}
17-
podSelector: {}
29+
- to:
30+
- ipBlock:
31+
cidr: 0.0.0.0/0
32+
except:
33+
- 10.0.0.0/8
34+
- 172.16.0.0/12
35+
- 192.168.0.0/16
36+
- to:
37+
- namespaceSelector: {}
38+
podSelector:
39+
matchLabels:
40+
k8s-app: kube-dns
41+
ports:
42+
- port: 53
43+
protocol: UDP
1844
{{- end }}

pkg/server/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func proxyHandler(logger logr.Logger, proxies map[string]*httputil.ReverseProxy,
9292

9393
// Overwrite the authorization header with the PAT token
9494
logger.Info("Authenticated request", "path", r.URL.Path)
95+
r.Host = target.Host
9596
r.Header.Del("Authorization")
9697
patB64 := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("pat:%s", pat)))
9798
r.Header.Add("Authorization", "Basic "+patB64)

0 commit comments

Comments
 (0)