1
0
angie-conv-image/doc/examples/njs
2024-11-18 11:30:16 +03:00
..
site doc: examples 2024-09-20 01:27:15 +03:00
Dockerfile bump version to 0.0.7 2024-11-18 11:30:16 +03:00
README.md bump version to 0.0.7 2024-11-18 11:30:16 +03:00

print env via NJS

Dockerfile:

FROM docker.io/rockdrilla/angie-conv:v0.0.7

COPY /site/ /etc/angie/site/

## install 'angie-module-njs' and process package contents
RUN apt-install-angie-mod.sh njs ; \
    apt-clean.sh

## load ngx_http_js_module
ENV NGX_HTTP_MODULES='njs'

configuration:

server {
    listen 8080;

    location / { return 204; }

    js_import ngx_env.js;
    location = /env
    {
        js_content ngx_env.report;
    }
}

NJS script:

function report(r) {
    var s = "";
    const keys = Object.keys(process.env).sort();
    for (const i in keys) {
        const k = keys[i];
        const v = process.env[k];
        s += k + '=' + v + "\n";
    }
    r.return(200, s);
}

export default { report };

Test URI e.g. with curl:

curl http://127.0.0.1:8080/env