Inject Custom Variable into ngx_http_fastcgi_module at Runtime from a Third-Party Module
10:20 14 May 2026

I am writing a third-party c NGINX module.

I want to do similar to apache module mod_env:

SetEnv MY_VAR hello

In normal NGINX config this works:

location ~ \.php$ {
    fastcgi_pass unix:/run/php/php-fpm.sock;
    fastcgi_param MY_VAR "hello";
}

Then PHP-FPM can read:

$_SERVER['MY_VAR']

My question is:

Can a third-party NGINX module add a new fastcgi_param dynamically at request runtime, without patching ngx_http_fastcgi_module, neither writing the variable in fastcgi_param in nginx.conf ?

c nginx module nginx-config nginx-location