{"id":32692857,"url":"https://github.com/fajarnugraha37/nginx-njs","last_synced_at":"2026-05-01T23:39:18.483Z","repository":{"id":319693624,"uuid":"1079351432","full_name":"fajarnugraha37/nginx-njs","owner":"fajarnugraha37","description":"Minimal Dockerized NGINX + njs playground ","archived":false,"fork":false,"pushed_at":"2025-10-19T16:32:14.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-01T23:38:58.464Z","etag":null,"topics":["docker","javascript","nginx","nginx-docker","njs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fajarnugraha37.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-19T16:26:27.000Z","updated_at":"2025-10-19T16:33:24.000Z","dependencies_parsed_at":"2025-10-20T00:34:32.441Z","dependency_job_id":null,"html_url":"https://github.com/fajarnugraha37/nginx-njs","commit_stats":null,"previous_names":["fajarnugraha37/nginx-njs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fajarnugraha37/nginx-njs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajarnugraha37%2Fnginx-njs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajarnugraha37%2Fnginx-njs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajarnugraha37%2Fnginx-njs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajarnugraha37%2Fnginx-njs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fajarnugraha37","download_url":"https://codeload.github.com/fajarnugraha37/nginx-njs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajarnugraha37%2Fnginx-njs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32517232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","javascript","nginx","nginx-docker","njs"],"created_at":"2025-11-01T16:02:02.869Z","updated_at":"2026-05-01T23:39:18.441Z","avatar_url":"https://github.com/fajarnugraha37.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nginx-njs-kit\n\nMinimal Dockerized NGINX + njs playground with **4 production-ish use cases**:\n\n1) **HMAC request signing** (`/sign`) – issues `X-Sign` based on method+uri+msec using env `HMAC_SECRET`.\n2) **Access gate + canary/feature flag routing** (`/api/hello`) – requires `x-api-key`, calls `/_int/flags` and internally redirects to `/v1/hello` or `/v2/hello`. Control population with env `FF_PERCENT` (0-100). Sticky per `Cookie: user=...`.\n3) **Response redaction** (`/report-filtered`) – masks long digit sequences from `/report` using an njs body filter.\n4) **Computed variables** – `js_set` populates `$hmac`, `$bucket`, `$ff` for logs/headers.\n\n\u003e This is **not** Node.js; njs is a tiny embeddable JS engine for request-time glue logic. Keep logic fast (\u003c1ms).\n\n## Quickstart\n\n```bash\ndocker build -t nginx-njs-kit .\ndocker run --name nginx-njs-kit --restart=unless-stopped -d   -e HMAC_SECRET=change-me   -e FF_PERCENT=50   -p 8080:8080 nginx-njs-kit\n\n# smoke\ncurl http://localhost:8080/\n```\n\n## Endpoints\n\n- `GET /sign` → 204 + headers `X-Time`, `X-Sign`\n- `GET /api/hello` (needs `x-api-key`) → internally serves `/v1/hello` or `/v2/hello`\n  - add `Cookie: user=alice` to get consistent bucketing\n  - tune `FF_PERCENT` to control v2 exposure\n- `GET /report` → raw JSON with PII-ish digits\n- `GET /report-filtered` → redacted JSON via njs header/body filters\n\n## Dev scripts\n\n```bash\nmake build\nmake start\nmake stop\nmake logs\nmake reload\nmake ssl\nmake ssh\n```\n\nWindows PowerShell test:\n\n```powershell\n.\\scripts\\test.ps1 -HostName localhost\n```\n\n## Notes\n\n- The HMAC uses Node-like `crypto` if the distro's njs module provides it; otherwise it falls back to a demo base64url (do not use in prod). On Debian/Ubuntu `libnginx-mod-http-njs` typically includes crypto.\n- All demos are same-process (no real upstream). In a real reverse-proxy, replace internal redirects with `proxy_pass` and forward headers (e.g., `proxy_set_header X-Sign $hmac;`).\n- Body filtering deletes `Content-Length` to force chunked encoding, as required when body size changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffajarnugraha37%2Fnginx-njs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffajarnugraha37%2Fnginx-njs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffajarnugraha37%2Fnginx-njs/lists"}