1
0
angie-conv-image/doc/examples/perl
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 Perl

Dockerfile:

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

COPY /site/ /etc/angie/site/

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

## load ngx_http_perl_module
ENV NGX_HTTP_MODULES='perl'

configuration:

perl_require ngx_env.pm;
server {
    listen 8080;

    location / { return 204; }

    location = /env
    {
        perl ngx_env::report;
    }
}

Perl script:

package ngx_env;

use nginx;

sub report {
    my $r = shift;

    my $s = "";
    for (sort keys %ENV) {
        $s = $s . "$_=$ENV{$_}\n";
    }

    $r->discard_request_body;
    $r->send_http_header;
    $r->print($s);

    return OK;
}

1;

__END__

Test URI e.g. with curl:

curl http://127.0.0.1:8080/env