Skip to content

Commit 98b11b0

Browse files
author
Rajat Chopra
committed
tls edge support
add nginx to build local images script
1 parent 1507472 commit 98b11b0

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

hack/build-local-images.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@
9696
},
9797
"files": {}
9898
},
99+
"nginx-router": {
100+
"directory": "router/nginx",
101+
"binaries": {
102+
"openshift": "/usr/bin/openshift"
103+
},
104+
"files": {
105+
".": "/var/lib/nginx"
106+
}
107+
},
99108
"haproxy-router": {
100109
"directory": "router/haproxy",
101110
"binaries": {

images/router/nginx/conf/nginx-config.template

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
backend for a route and contains all the endpoints for the service
55
*/}}
66
{{- define "/var/lib/nginx/conf/nginx.config" -}}
7+
{{- $workingDir := .WorkingDir }}
78
#user www www; ## Default: nobody
89
worker_processes 5; ## Default: 1
910
error_log /var/lib/nginx/logs/error.log;
@@ -32,10 +33,8 @@ http {
3233

3334

3435
{{- range $cfgIdx, $cfg := .State }}
35-
{{- if (eq $cfg.TLSTermination "") }}
3636

37-
# Plain http backend
38-
upstream be_http_{{$cfgIdx}} {
37+
upstream be_{{$cfg.Namespace}}_{{$cfg.Name}} {
3938
{{- range $serviceUnitName, $weight := $cfg.ServiceUnitNames }}
4039
{{- with $serviceUnit := index $.ServiceUnits $serviceUnitName }}
4140
{{- range $idx, $endpoint := endpointsForAlias $cfg $serviceUnit }}
@@ -46,15 +45,26 @@ http {
4645
}
4746

4847
server { # simple load balancing
48+
{{- if (eq $cfg.TLSTermination "") }}
4949
listen 80;
50+
{{- else }}
51+
listen 443;
52+
{{ end -}}
53+
5054
server_name {{$cfg.Host}};
51-
access_log /var/lib/nginx/logs/be_http_{{$cfgIdx}}.log main;
55+
{{- if and (ne $cfg.Host "") (or (eq $cfg.TLSTermination "edge") (eq $cfg.TLSTermination "reencrypt")) -}}
56+
{{ $cert := index $cfg.Certificates $cfg.Host -}}
57+
{{ if ne $cert.Contents "" }}
58+
ssl_certificate {{$workingDir}}/certs/{{$cfgIdx}}.pem;
59+
ssl_certificate_key {{$workingDir}}/certs/{{$cfgIdx}}.pem;
60+
{{ end -}}
61+
{{ end -}}
62+
access_log /var/lib/nginx/logs/be_{{$cfgIdx}}.log main;
5263

5364
location / {
54-
proxy_pass http://be_http_{{$cfgIdx}};
65+
proxy_pass http://be_{{$cfg.Namespace}}_{{$cfg.Name}};
5566
}
5667
}
57-
{{ end -}}{{/* end if plain http */}}
5868
{{ end -}}{{/* end all routes */}}
5969
}
6070
{{ end -}}{{/* end config file */}}

images/router/nginx/reload-nginx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
set -o nounset
44

55
config_file=/var/lib/nginx/conf/nginx.config
6-
old_pids=$(ps -A -opid,args | grep nginx | egrep -v -e 'grep|reload-nginx' | awk '{print $1}' | tr '\n' ' ')
7-
8-
reload_status=0
9-
if [ -n "$old_pids" ]; then
10-
/usr/sbin/nginx -c ${config_file} -s reload
6+
if [ -f /var/lib/nginx/logs/nginx.pid ]; then
7+
/usr/sbin/nginx -c ${config_file} -s reload
118
reload_status=$?
129
else
1310
/usr/sbin/nginx -c ${config_file}

0 commit comments

Comments
 (0)