12
12
# setup custom paths that do not require root access
13
13
pid {{ .PID }};
14
14
15
+ # enables the use of “just-in-time compilation” for the regular expressions known by the time of configuration parsing
16
+ pcre_jit on;
17
+
15
18
{{ if $cfg.UseGeoIP2 }}
16
19
load_module /etc/nginx/modules/ngx_http_geoip2_module.so;
17
20
{{ end }}
@@ -98,11 +101,11 @@ http {
98
101
end
99
102
100
103
{{ if $all.EnableMetrics }}
101
- ok, res = pcall(require, "monitor ")
104
+ ok, res = pcall(require, "pbmetrics ")
102
105
if not ok then
103
106
error("require failed: " .. tostring(res))
104
107
else
105
- monitor = res
108
+ pbmetrics = res
106
109
end
107
110
{{ end }}
108
111
@@ -127,11 +130,9 @@ http {
127
130
init_worker_by_lua_block {
128
131
lua_ingress.init_worker()
129
132
balancer.init_worker()
130
- {{ if $all.EnableMetrics }}
131
- monitor.init_worker({{ $all.MonitorMaxBatchSize }})
132
- {{ end }}
133
133
134
134
plugins.run()
135
+ pbmetrics.init_worker()
135
136
}
136
137
137
138
{{/* Enable the real_ip module only if we use either X-Forwarded headers or Proxy Protocol. */}}
@@ -415,6 +416,15 @@ http {
415
416
{{ $reqUri }} 0;{{ end }}
416
417
default 1;
417
418
}
419
+ map $server_name $total_upstream_response_time {
420
+ default 0;
421
+ }
422
+ map $server_name $upstream_retries {
423
+ default 0;
424
+ }
425
+ map $server_name $formatted_status {
426
+ default $status;
427
+ }
418
428
419
429
{{ if or $cfg.DisableAccessLog $cfg.DisableHTTPAccessLog }}
420
430
access_log off;
@@ -955,14 +965,15 @@ stream {
955
965
proxy_set_header Host $best_http_host;
956
966
957
967
set $proxy_upstream_name {{ $upstreamName | quote }};
968
+ set $formatted_status $status;
969
+ set $upstream_retries "0";
970
+ set $total_upstream_response_time "0";
958
971
959
972
rewrite (.*) / break;
960
973
961
974
proxy_pass http://upstream_balancer;
962
975
log_by_lua_block {
963
- {{ if $enableMetrics }}
964
- monitor.call()
965
- {{ end }}
976
+ pbmetrics.call()
966
977
}
967
978
}
968
979
{{ end }}
@@ -1010,10 +1021,13 @@ stream {
1010
1021
{{ buildHTTPSListener $all $server.Hostname }}
1011
1022
1012
1023
set $proxy_upstream_name "-";
1024
+ set $formatted_status $status;
1025
+ set $upstream_retries "0";
1026
+ set $total_upstream_response_time "0";
1013
1027
1014
1028
{{ if not ( empty $server.CertificateAuth.MatchCN ) }}
1015
1029
{{ if gt (len $server.CertificateAuth.MatchCN) 0 }}
1016
- if ( $ssl_client_s_dn !~ {{ $server.CertificateAuth.MatchCN }} ) {
1030
+ if ( $ssl_client_s_dn !~ {{ $server.CertificateAuth.MatchCN | quote }} ) {
1017
1031
return 403 "client certificate unauthorized";
1018
1032
}
1019
1033
{{ end }}
@@ -1172,6 +1186,10 @@ stream {
1172
1186
proxy_set_header X-Auth-Request-Redirect $request_uri;
1173
1187
{{ end }}
1174
1188
1189
+ {{ if not (contains $externalAuth.AuthSnippet "proxy_connect_timeout") }}
1190
+ proxy_connect_timeout 15s;
1191
+ {{ end }}
1192
+
1175
1193
{{ if $externalAuth.AuthCacheKey }}
1176
1194
proxy_buffering "on";
1177
1195
{{ else }}
@@ -1219,7 +1237,7 @@ stream {
1219
1237
set $target {{ changeHostPort $externalAuth.URL $authUpstreamName }};
1220
1238
{{ else }}
1221
1239
proxy_http_version {{ $location.Proxy.ProxyHTTPVersion }};
1222
- set $target {{ $externalAuth.URL }};
1240
+ set $target {{ $externalAuth.URL | quote }};
1223
1241
{{ end }}
1224
1242
proxy_pass $target;
1225
1243
}
@@ -1255,10 +1273,12 @@ stream {
1255
1273
set $location_path {{ $ing.Path | escapeLiteralDollar | quote }};
1256
1274
set $global_rate_limit_exceeding n;
1257
1275
1276
+ set $content_kind "";
1277
+
1258
1278
{{ buildOpentelemetryForLocation $all.Cfg.EnableOpentelemetry $all.Cfg.OpentelemetryTrustIncomingSpan $location }}
1259
1279
1260
1280
{{ if $location.Mirror.Source }}
1261
- mirror {{ $location.Mirror.Source }};
1281
+ mirror {{ $location.Mirror.Source | quote }};
1262
1282
mirror_request_body {{ $location.Mirror.RequestBody }};
1263
1283
{{ end }}
1264
1284
@@ -1285,11 +1305,9 @@ stream {
1285
1305
1286
1306
log_by_lua_block {
1287
1307
balancer.log()
1288
- {{ if $all.EnableMetrics }}
1289
- monitor.call()
1290
- {{ end }}
1291
1308
1292
1309
plugins.run()
1310
+ pbmetrics.call()
1293
1311
}
1294
1312
1295
1313
{{ if not $location.Logs.Access }}
@@ -1577,14 +1595,15 @@ stream {
1577
1595
1578
1596
{{ if eq $server.Hostname "_" }}
1579
1597
# health checks in cloud providers require the use of port {{ $all.ListenPorts.HTTP }}
1580
- location {{ $all.HealthzURI }} {
1598
+ location = {{ $all.HealthzURI }} {
1581
1599
1582
1600
{{ if $all.Cfg.EnableOpentelemetry }}
1583
1601
opentelemetry off;
1584
1602
{{ end }}
1585
1603
1586
1604
access_log off;
1587
- return 200;
1605
+ proxy_set_header D8s-External-Check "True";
1606
+ proxy_pass http://127.0.0.1:10254;
1588
1607
}
1589
1608
1590
1609
# this is required to avoid error if nginx is being monitored
0 commit comments