Skip to content

Commit 22158a9

Browse files
feat: Add nginx njs dynamic module in base image
Signed-off-by: Anurag Rajawat <[email protected]>
1 parent 0207d18 commit 22158a9

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

docs/user-guide/nginx-configuration/configmap.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ The following table shows a configuration option's name, type, and the default v
102102
| [use-geoip2](#use-geoip2) | bool | "false" | |
103103
| [geoip2-autoreload-in-minutes](#geoip2-autoreload-in-minutes) | int | "0" | |
104104
| [enable-brotli](#enable-brotli) | bool | "false" | |
105+
| [enable-njs](#enable-njs) | bool | "false" | |
105106
| [brotli-level](#brotli-level) | int | 4 | |
106107
| [brotli-min-length](#brotli-min-length) | int | 20 | |
107108
| [brotli-types](#brotli-types) | string | "application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/javascript text/plain text/x-component" | |
@@ -733,6 +734,9 @@ _**default:**_ false
733734

734735
> __Note:__ Brotli does not works in Safari < 11. For more information see [https://caniuse.com/#feat=brotli](https://caniuse.com/#feat=brotli)
735736
737+
## enable-njs
738+
Enables or disables [njs](https://nginx.org/en/docs/njs/) module. _**default: false**_
739+
736740
## brotli-level
737741

738742
Sets the Brotli Compression Level that will be used. _**default:**_ 4

images/nginx/rootfs/build.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ export OPENTELEMETRY_CPP_VERSION="v1.11.0"
106106
# Check on https://github.com/open-telemetry/opentelemetry-proto
107107
export OPENTELEMETRY_PROTO_VERSION="v1.1.0"
108108

109+
# http://hg.nginx.org/njs
110+
export NGINX_NJS_VERSION="0.8.4"
111+
109112
export BUILD_PATH=/tmp/build
110113

111114
ARCH=$(uname -m)
@@ -276,6 +279,9 @@ get_src efb767487ea3f6031577b9b224467ddbda2ad51a41c5867a47582d4ad85d609e \
276279
get_src d74f86ada2329016068bc5a243268f1f555edd620b6a7d6ce89295e7d6cf18da \
277280
"https://github.com/microsoft/mimalloc/archive/${MIMALOC_VERSION}.tar.gz" "mimalloc"
278281

282+
get_src 8191bff8491af9169a92e30e383ef8614717b0c6d40913d83b95051031e92321 \
283+
"http://hg.nginx.org/njs/archive/${NGINX_NJS_VERSION}.tar.gz" "njs"
284+
279285
# improve compilation times
280286
CORES=$(($(grep -c ^processor /proc/cpuinfo) - 1))
281287

@@ -481,7 +487,8 @@ WITH_MODULES=" \
481487
--add-dynamic-module=$BUILD_PATH/nginx-http-auth-digest \
482488
--add-dynamic-module=$BUILD_PATH/ModSecurity-nginx \
483489
--add-dynamic-module=$BUILD_PATH/ngx_http_geoip2_module \
484-
--add-dynamic-module=$BUILD_PATH/ngx_brotli"
490+
--add-dynamic-module=$BUILD_PATH/ngx_brotli \
491+
--add-dynamic-module=$BUILD_PATH/njs/nginx"
485492

486493
./configure \
487494
--prefix=/usr/local/nginx \

internal/ingress/controller/config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ type Configuration struct {
447447
// MIME Types that will be compressed on-the-fly using Brotli module
448448
BrotliTypes string `json:"brotli-types,omitempty"`
449449

450+
// Enables NGINX JS
451+
EnableNJS bool `json:"enable-njs,omitempty"`
452+
450453
// Enables or disables the HTTP/2 support in secure connections
451454
// http://nginx.org/en/docs/http/ngx_http_v2_module.html
452455
// Default: true
@@ -767,6 +770,7 @@ func NewDefault() Configuration {
767770
BrotliLevel: 4,
768771
BrotliMinLength: 20,
769772
BrotliTypes: brotliTypes,
773+
EnableNJS: false,
770774
ClientHeaderBufferSize: "1k",
771775
ClientHeaderTimeout: 60,
772776
ClientBodyBufferSize: "8k",

rootfs/etc/nginx/template/nginx.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ load_module /etc/nginx/modules/ngx_http_modsecurity_module.so;
3333
load_module /etc/nginx/modules/otel_ngx_module.so;
3434
{{ end }}
3535

36+
{{ if $cfg.EnableNJS }}
37+
load_module /etc/nginx/modules/ngx_http_js_module.so;
38+
{{ end }}
39+
3640
daemon off;
3741

3842
worker_processes {{ $cfg.WorkerProcesses }};

0 commit comments

Comments
 (0)