Skip to content

Commit f299935

Browse files
author
Kate Osborn
committed
Add nginx 500 and 502 servers
1 parent 802fa6d commit f299935

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

deploy/manifests/nginx-gateway.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ spec:
8282
volumes:
8383
- name: nginx-config
8484
emptyDir: { }
85+
- name: var-lib-nginx
86+
emptyDir: { }
8587
- name: njs-modules
8688
configMap:
8789
name: njs-modules
@@ -92,6 +94,8 @@ spec:
9294
volumeMounts:
9395
- name: nginx-config
9496
mountPath: /etc/nginx
97+
- name: var-lib-nginx
98+
mountPath: /var/lib/nginx
9599
containers:
96100
- image: ghcr.io/nginxinc/nginx-kubernetes-gateway:edge
97101
imagePullPolicy: Always
@@ -118,5 +122,7 @@ spec:
118122
volumeMounts:
119123
- name: nginx-config
120124
mountPath: /etc/nginx
125+
- name: var-lib-nginx
126+
mountPath: /var/lib/nginx
121127
- name: njs-modules
122128
mountPath: /usr/lib/nginx/modules/njs

internal/nginx/config/template/servers.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,17 @@ server {
5353
}
5454
{{ end }}
5555
{{ end }}
56+
server {
57+
listen unix:/var/lib/nginx/nginx-502-server.sock;
58+
access_log off;
59+
60+
return 502;
61+
}
62+
63+
server {
64+
listen unix:/var/lib/nginx/nginx-500-server.sock;
65+
access_log off;
66+
67+
return 500;
68+
}
5669
`

internal/nginx/config/upstreams.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
const (
1212
// nginx502Server is used as a backend for services that cannot be resolved (have no IP address).
1313
nginx502Server = "unix:/var/lib/nginx/nginx-502-server.sock"
14+
// nginx500Server is used as a server for the invalid backend ref upstream.
15+
nginx500Server = "unix:/var/lib/nginx/nginx-500-server.sock"
1416
// invalidBackendRef is used as an upstream name for invalid backend references.
1517
invalidBackendRef = "invalid-backend-ref"
1618
)
@@ -65,7 +67,7 @@ func createInvalidBackendRefUpstream() http.Upstream {
6567
Name: invalidBackendRef,
6668
Servers: []http.UpstreamServer{
6769
{
68-
Address: nginx502Server,
70+
Address: nginx500Server,
6971
},
7072
},
7173
}

internal/nginx/config/upstreams_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestCreateUpstreams(t *testing.T) {
128128
Name: invalidBackendRef,
129129
Servers: []http.UpstreamServer{
130130
{
131-
Address: nginx502Server,
131+
Address: nginx500Server,
132132
},
133133
},
134134
},

0 commit comments

Comments
 (0)