Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add njs to nginx build #11248

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions images/nginx-1.25/rootfs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export OPENTELEMETRY_CPP_VERSION="v1.11.0"
# Check on https://github.com/open-telemetry/opentelemetry-proto
export OPENTELEMETRY_PROTO_VERSION="v1.1.0"

# http://hg.nginx.org/njs
export NGINX_NJS_VERSION="0.8.3"


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

export BUILD_PATH=/tmp/build

ARCH=$(uname -m)
Expand All @@ -123,7 +127,7 @@ get_src()

echo "Downloading $url"

curl -sSL "$url" -o "$f"
curl --retry 5 -sSL "$url" -o "$f"
# TODO: Reenable checksum verification but make it smarter
# echo "$hash $f" | sha256sum -c - || exit 10
if [ ! -z "$dest" ]; then
Expand Down Expand Up @@ -282,6 +286,10 @@ get_src 0fb790e394510e73fdba1492e576aaec0b8ee9ef08e3e821ce253a07719cf7ea \
get_src d74f86ada2329016068bc5a243268f1f555edd620b6a7d6ce89295e7d6cf18da \
"https://github.com/microsoft/mimalloc/archive/${MIMALOC_VERSION}.tar.gz" "mimalloc"


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

get_src b7afc0e67cf1be8f9ea4b1e6133026e7fb6b8953fafc947d0778ca48a0aa1e64 \
"http://hg.nginx.org/njs/archive/${NGINX_NJS_VERSION}.tar.gz"

# improve compilation times
CORES=$(($(grep -c ^processor /proc/cpuinfo) - 1))

Expand Down Expand Up @@ -489,7 +497,8 @@ WITH_MODULES=" \
--add-dynamic-module=$BUILD_PATH/nginx-http-auth-digest \
--add-dynamic-module=$BUILD_PATH/ModSecurity-nginx \
--add-dynamic-module=$BUILD_PATH/ngx_http_geoip2_module \
--add-dynamic-module=$BUILD_PATH/ngx_brotli"
--add-dynamic-module=$BUILD_PATH/ngx_brotli \
--add-module=$BUILD_PATH/njs/nginx"

./configure \
--prefix=/usr/local/nginx \
Expand Down
4 changes: 4 additions & 0 deletions internal/ingress/controller/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@
// MIME Types that will be compressed on-the-fly using Brotli module
BrotliTypes string `json:"brotli-types,omitempty"`

//Enables NGINX JS

Check failure on line 455 in internal/ingress/controller/config/config.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Enables NGINX JS
// Enables NGINX JS

EnableNJS bool `json:"enable-njs,omitempty`

Check failure on line 456 in internal/ingress/controller/config/config.go

View workflow job for this annotation

GitHub Actions / lint

structtag: struct field tag `json:"enable-njs,omitempty` not compatible with reflect.StructTag.Get: bad syntax for struct tag value (govet)

// Enables or disables the HTTP/2 support in secure connections
// http://nginx.org/en/docs/http/ngx_http_v2_module.html
// Default: true
Expand Down Expand Up @@ -790,6 +793,7 @@
BrotliLevel: 4,
BrotliMinLength: 20,
BrotliTypes: brotliTypes,
EnableNJS: false,
ClientHeaderBufferSize: "1k",
ClientHeaderTimeout: 60,
ClientBodyBufferSize: "8k",
Expand Down
2 changes: 2 additions & 0 deletions pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@
disableSyncEvents = flags.Bool("disable-sync-events", false, "Disables the creation of 'Sync' event resources")

enableTopologyAwareRouting = flags.Bool("enable-topology-aware-routing", false, "Enable topology aware routing feature, needs service object annotation service.kubernetes.io/topology-mode sets to auto.")

Check failure on line 231 in pkg/flags/flags.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofmt`-ed with `-s` (gofmt)

Comment on lines +231 to +232
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

)

flags.StringVar(&nginx.MaxmindMirror, "maxmind-mirror", "", `Maxmind mirror url (example: http://geoip.local/databases.`)
Expand Down
4 changes: 4 additions & 0 deletions rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ load_module /etc/nginx/modules/ngx_http_modsecurity_module.so;
load_module /etc/nginx/modules/otel_ngx_module.so;
{{ end }}

{{ if $cfg.EnableNJS }}
load_module /etc/nginx/modules/ngx_http_js_module.so;
{{ end }}

daemon off;

worker_processes {{ $cfg.WorkerProcesses }};
Expand Down