Skip to content

Commit

Permalink
Add nginx 500 and 502 servers
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-osborn committed Oct 13, 2022
1 parent 802fa6d commit f299935
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions deploy/manifests/nginx-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ spec:
volumes:
- name: nginx-config
emptyDir: { }
- name: var-lib-nginx
emptyDir: { }
- name: njs-modules
configMap:
name: njs-modules
Expand All @@ -92,6 +94,8 @@ spec:
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx
- name: var-lib-nginx
mountPath: /var/lib/nginx
containers:
- image: ghcr.io/nginxinc/nginx-kubernetes-gateway:edge
imagePullPolicy: Always
Expand All @@ -118,5 +122,7 @@ spec:
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx
- name: var-lib-nginx
mountPath: /var/lib/nginx
- name: njs-modules
mountPath: /usr/lib/nginx/modules/njs
13 changes: 13 additions & 0 deletions internal/nginx/config/template/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,17 @@ server {
}
{{ end }}
{{ end }}
server {
listen unix:/var/lib/nginx/nginx-502-server.sock;
access_log off;
return 502;
}
server {
listen unix:/var/lib/nginx/nginx-500-server.sock;
access_log off;
return 500;
}
`
4 changes: 3 additions & 1 deletion internal/nginx/config/upstreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
const (
// nginx502Server is used as a backend for services that cannot be resolved (have no IP address).
nginx502Server = "unix:/var/lib/nginx/nginx-502-server.sock"
// nginx500Server is used as a server for the invalid backend ref upstream.
nginx500Server = "unix:/var/lib/nginx/nginx-500-server.sock"
// invalidBackendRef is used as an upstream name for invalid backend references.
invalidBackendRef = "invalid-backend-ref"
)
Expand Down Expand Up @@ -65,7 +67,7 @@ func createInvalidBackendRefUpstream() http.Upstream {
Name: invalidBackendRef,
Servers: []http.UpstreamServer{
{
Address: nginx502Server,
Address: nginx500Server,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/nginx/config/upstreams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestCreateUpstreams(t *testing.T) {
Name: invalidBackendRef,
Servers: []http.UpstreamServer{
{
Address: nginx502Server,
Address: nginx500Server,
},
},
},
Expand Down

0 comments on commit f299935

Please sign in to comment.