Skip to content

Commit fb037d4

Browse files
authored
Merge branch 'main' into chore/remove_omitted_comment
2 parents a6fcf03 + 573828e commit fb037d4

File tree

15 files changed

+34
-18
lines changed

15 files changed

+34
-18
lines changed

build/Dockerfile.nginx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,10 @@ RUN --mount=type=bind,from=nginx-files,src=nginx_signing.rsa.pub,target=/etc/apk
1616
printf "%s\n" "https://packages.nginx.org/nginx-agent/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" >> /etc/apk/repositories \
1717
&& apk add --no-cache nginx-agent=${NGINX_AGENT_VERSION#v}
1818

19-
RUN apk add --no-cache libcap bash \
19+
RUN apk add --no-cache bash \
2020
&& mkdir -p /usr/lib/nginx/modules \
21-
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \
22-
&& setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx \
23-
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \
24-
&& setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \
2521
# Update packages for CVE-2025-32414 and CVE-2025-32415
2622
&& apk --no-cache upgrade libxml2 \
27-
&& apk del libcap \
2823
# forward request and error logs to docker log collector
2924
&& ln -sf /dev/stdout /var/log/nginx/access.log \
3025
&& ln -sf /dev/stderr /var/log/nginx/error.log

build/Dockerfile.nginxplus

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/apk/cert.pem,mode=0644 \
2222
&& printf "%s\n" "https://pkgs.nginx.com/nginx-agent/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" >> /etc/apk/repositories \
2323
&& apk add --no-cache nginx-plus nginx-plus-module-njs nginx-plus-module-otel nginx-agent=${NGINX_AGENT_VERSION#v}
2424

25-
RUN apk add --no-cache libcap bash \
25+
RUN apk add --no-cache bash \
2626
&& mkdir -p /usr/lib/nginx/modules \
27-
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \
28-
&& setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx \
29-
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \
30-
&& setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \
31-
&& apk del libcap \
3227
# forward request and error logs to docker log collector
3328
&& ln -sf /dev/stdout /var/log/nginx/access.log \
3429
&& ln -sf /dev/stderr /var/log/nginx/error.log

charts/nginx-gateway-fabric/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ spec:
3535
{{- end }}
3636
{{- end }}
3737
spec:
38+
automountServiceAccountToken: true
3839
containers:
3940
- args:
4041
- controller

charts/nginx-gateway-fabric/templates/scc.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ metadata:
4444
name: {{ include "nginx-gateway.scc-name" . }}-nginx
4545
labels:
4646
{{- include "nginx-gateway.labels" . | nindent 4 }}
47+
allowPrivilegeEscalation: false
4748
allowHostDirVolumePlugin: false
4849
allowHostIPC: false
4950
allowHostNetwork: false
@@ -69,8 +70,6 @@ seLinuxContext:
6970
type: MustRunAs
7071
seccompProfiles:
7172
- runtime/default
72-
allowedCapabilities:
73-
- NET_BIND_SERVICE
7473
requiredDropCapabilities:
7574
- ALL
7675
volumes:

charts/nginx-gateway-fabric/templates/serviceaccount.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata:
77
{{- include "nginx-gateway.labels" . | nindent 4 }}
88
annotations:
99
{{- toYaml .Values.nginxGateway.serviceAccount.annotations | nindent 4 }}
10+
automountServiceAccountToken: false
1011
{{- if or .Values.nginxGateway.serviceAccount.imagePullSecret .Values.nginxGateway.serviceAccount.imagePullSecrets }}
1112
imagePullSecrets:
1213
{{- if .Values.nginxGateway.serviceAccount.imagePullSecret }}

deploy/azure/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -252,6 +253,7 @@ spec:
252253
app.kubernetes.io/instance: nginx-gateway
253254
app.kubernetes.io/name: nginx-gateway
254255
spec:
256+
automountServiceAccountToken: true
255257
containers:
256258
- args:
257259
- controller

deploy/default/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -252,6 +253,7 @@ spec:
252253
app.kubernetes.io/instance: nginx-gateway
253254
app.kubernetes.io/name: nginx-gateway
254255
spec:
256+
automountServiceAccountToken: true
255257
containers:
256258
- args:
257259
- controller

deploy/experimental-nginx-plus/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -256,6 +257,7 @@ spec:
256257
app.kubernetes.io/instance: nginx-gateway
257258
app.kubernetes.io/name: nginx-gateway
258259
spec:
260+
automountServiceAccountToken: true
259261
containers:
260262
- args:
261263
- controller

deploy/experimental/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -256,6 +257,7 @@ spec:
256257
app.kubernetes.io/instance: nginx-gateway
257258
app.kubernetes.io/name: nginx-gateway
258259
spec:
260+
automountServiceAccountToken: true
259261
containers:
260262
- args:
261263
- controller

deploy/nginx-plus/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -252,6 +253,7 @@ spec:
252253
app.kubernetes.io/instance: nginx-gateway
253254
app.kubernetes.io/name: nginx-gateway
254255
spec:
256+
automountServiceAccountToken: true
255257
containers:
256258
- args:
257259
- controller

deploy/nodeport/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -252,6 +253,7 @@ spec:
252253
app.kubernetes.io/instance: nginx-gateway
253254
app.kubernetes.io/name: nginx-gateway
254255
spec:
256+
automountServiceAccountToken: true
255257
containers:
256258
- args:
257259
- controller

deploy/openshift/deploy.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -273,6 +274,7 @@ spec:
273274
app.kubernetes.io/instance: nginx-gateway
274275
app.kubernetes.io/name: nginx-gateway
275276
spec:
277+
automountServiceAccountToken: true
276278
containers:
277279
- args:
278280
- controller
@@ -527,9 +529,8 @@ allowHostIPC: false
527529
allowHostNetwork: false
528530
allowHostPID: false
529531
allowHostPorts: false
532+
allowPrivilegeEscalation: false
530533
allowPrivilegedContainer: false
531-
allowedCapabilities:
532-
- NET_BIND_SERVICE
533534
apiVersion: security.openshift.io/v1
534535
fsGroup:
535536
ranges:

deploy/snippets-filters-nginx-plus/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -254,6 +255,7 @@ spec:
254255
app.kubernetes.io/instance: nginx-gateway
255256
app.kubernetes.io/name: nginx-gateway
256257
spec:
258+
automountServiceAccountToken: true
257259
containers:
258260
- args:
259261
- controller

deploy/snippets-filters/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nginx-gateway
55
---
66
apiVersion: v1
7+
automountServiceAccountToken: false
78
kind: ServiceAccount
89
metadata:
910
labels:
@@ -254,6 +255,7 @@ spec:
254255
app.kubernetes.io/instance: nginx-gateway
255256
app.kubernetes.io/name: nginx-gateway
256257
spec:
258+
automountServiceAccountToken: true
257259
containers:
258260
- args:
259261
- controller

internal/controller/provisioner/objects.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ func (p *NginxProvisioner) buildNginxResourceObjects(
117117
)
118118

119119
serviceAccount := &corev1.ServiceAccount{
120-
ObjectMeta: objectMeta,
120+
ObjectMeta: objectMeta,
121+
AutomountServiceAccountToken: helpers.GetPointer(false),
121122
}
122123

123124
var openshiftObjs []client.Object
@@ -608,15 +609,16 @@ func (p *NginxProvisioner) buildNginxPodTemplateSpec(
608609
Annotations: podAnnotations,
609610
},
610611
Spec: corev1.PodSpec{
612+
AutomountServiceAccountToken: helpers.GetPointer(true),
611613
Containers: []corev1.Container{
612614
{
613615
Name: "nginx",
614616
Image: image,
615617
ImagePullPolicy: pullPolicy,
616618
Ports: containerPorts,
617619
SecurityContext: &corev1.SecurityContext{
620+
AllowPrivilegeEscalation: helpers.GetPointer(false),
618621
Capabilities: &corev1.Capabilities{
619-
Add: []corev1.Capability{"NET_BIND_SERVICE"},
620622
Drop: []corev1.Capability{"ALL"},
621623
},
622624
ReadOnlyRootFilesystem: helpers.GetPointer(true),
@@ -689,6 +691,12 @@ func (p *NginxProvisioner) buildNginxPodTemplateSpec(
689691
SecurityContext: &corev1.PodSecurityContext{
690692
FSGroup: helpers.GetPointer[int64](1001),
691693
RunAsNonRoot: helpers.GetPointer(true),
694+
Sysctls: []corev1.Sysctl{
695+
{
696+
Name: "net.ipv4.ip_unprivileged_port_start",
697+
Value: "0",
698+
},
699+
},
692700
},
693701
Volumes: []corev1.Volume{
694702
{

0 commit comments

Comments
 (0)