Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx+php-fpm environment variables #1106

Open
smeinecke opened this issue Mar 10, 2023 · 1 comment
Open

nginx+php-fpm environment variables #1106

smeinecke opened this issue Mar 10, 2023 · 1 comment
Assignees

Comments

@smeinecke
Copy link

smeinecke commented Mar 10, 2023

Is your feature request related to a problem? Please describe.
In many PHP projects, environment variables like "environment" must be set to determine whether the current hostname is used for the "production" or the "test" environment. Typo3 uses "TYPO3_CONTEXT" for example.

If froxlor is used with nginx and php-fpm, it is currently not possible to set this environment variable. The location @php block is hardcoded in lib/Froxlor/Cron/Http/Nginx.php and cannot be changed per host. In PHP-FPM configuration it is possible to define multiple php-configs, but it is not possible to define a variable as env - only for php_flag, php_value, php_admin_flag and php_admin_value.

The only way to change the environment variable would be to define it globally in /etc/nginx/fastcgi_params (which is global and not changeable per host) or via an additional configuration in the php-fpm version configuration (not php-config itself), which is again global.

Describe the solution you'd like
Either change the interface to allow to extend the location @php block in nginx or add additional config block in froxlor/admin_settings.php?page=overview&part=phpfpm to define names as "env" variables to set in custom php configurations.

Describe alternatives you've considered
Right now, I "just" added a nginx map in my global nginx config to define a variable $typo3_context based on the current hostname and set this on all hosts via the fastcgi_params:

fastcgi_param TYPO3_CONTEXT $typo3_context;

@d00p d00p self-assigned this Mar 10, 2023
@d00p
Copy link
Member

d00p commented Jan 14, 2024

Just tested this and our config-merger correctly adds what you need, just specify the following to the Special vHost settings for the corresponding domain and the fastcgi_param line will be added to the resulting location @php block:

domain vhost settings:

location @php {
       	fastcgi_param  TYPO3_CONTEXT      $typo3_context;
}

Resulting vhost content (partly):

location @php {
        try_files $1 =404;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        include snippets/fastcgi-php.conf;
        fastcgi_param [...];
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param TYPO3_CONTEXT $typo3_context;
}

Does this by any chance work for you too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants