Decision-making in NGINX
You may find yourself trying to bend NGINX's configuration directives in ways that they were not meant to be used. This is frequently seen in configurations where there are a lot of if
checks to try to emulate some sort of logic chain. A better option would be to use NGINX's embedded perl
module. With this module, you will be able to use the flexibility of Perl to achieve your configuration goals.
The perl module is not built by default, so it needs to be enabled with the --with-http_perl_module
configure switch. A minimum of Perl 5.6.1 is required. Ensure as well that your Perl was built with -Dusemultiplicity=yes
(or -Dusethreads=yes
) and -Dusemymalloc=no
. NGINX configuration reloads will cause the perl
module to leak memory over time, so this last parameter is included to help mitigate that problem.
After having built NGINX with embedded Perl, the following directives are available:
Perl module directives |
Explanation |
---|---|
|
This directive activates a Perl handler... |