initial commit
This commit is contained in:
11
doc/examples/perl/Dockerfile
Normal file
11
doc/examples/perl/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM docker.io/rockdrilla/angie-conv:v0.0.1
|
||||
SHELL [ "/bin/sh", "-ec" ]
|
||||
|
||||
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'
|
70
doc/examples/perl/README.md
Normal file
70
doc/examples/perl/README.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# print env via Perl
|
||||
|
||||
Dockerfile:
|
||||
|
||||
```dockerfile
|
||||
FROM docker.io/rockdrilla/angie-conv:v0.0.1
|
||||
|
||||
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:
|
||||
|
||||
```nginx
|
||||
perl_require ngx_env.pm;
|
||||
server {
|
||||
listen 8080;
|
||||
|
||||
location / { return 204; }
|
||||
|
||||
location = /env
|
||||
{
|
||||
perl ngx_env::report;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Perl script:
|
||||
|
||||
```perl
|
||||
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`:
|
||||
```sh
|
||||
curl http://127.0.0.1:8080/env
|
||||
```
|
11
doc/examples/perl/site/http-env-perl.conf
Normal file
11
doc/examples/perl/site/http-env-perl.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
perl_require ngx_env.pm;
|
||||
server {
|
||||
listen 8080;
|
||||
|
||||
location / { return 204; }
|
||||
|
||||
location = /env
|
||||
{
|
||||
perl ngx_env::report;
|
||||
}
|
||||
}
|
22
doc/examples/perl/site/ngx_env.pm
Normal file
22
doc/examples/perl/site/ngx_env.pm
Normal file
@@ -0,0 +1,22 @@
|
||||
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__
|
Reference in New Issue
Block a user