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

fastcgi_params in virtual host of nginx #61

Open
mpastas opened this issue May 13, 2017 · 4 comments
Open

fastcgi_params in virtual host of nginx #61

mpastas opened this issue May 13, 2017 · 4 comments

Comments

@mpastas
Copy link

mpastas commented May 13, 2017

Hi guys!

I'm wondering if it is possible to set fastcgi_param in virtual hosts. Currently the only file that make any change in the environment variables is the default one /etc/nginx/fastcgi_params

What I'm trying:

    location ~ \.php$ {

        fastcgi_param TESTVAR  testvar;

    }
@mblaschke
Copy link
Member

Just upload your own configuration file to /opt/docker/etc/nginx/vhost.common.d/10-php.conf (source eg. https://github.com/webdevops/Dockerfile/blob/develop/docker/php-nginx/debian-7/conf/etc/nginx/vhost.common.d/10-php.conf)

ENV vars are not enough?

@htuscher
Copy link
Member

Or if you dynamically want to modify the config, you could do also use the new service bootstrapping in combination with go-replace to dynamically add some things to config files.

See https://gist.github.com/hhoechtl/78bce01aefc4a65c1ffd337872f3f01f

@mblaschke
Copy link
Member

mblaschke commented May 14, 2017

@hhoechtl
you can also use (with go-replace 1.1.x):

go-replace --mode=lineinfile --lineinfile-before='}' --regex \
    -s 'fastcgi_param TESTVAR' 
    -r 'fastcgi_param TESTVAR  testvar;' 
    -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf

Which will replaces the line fastcgi_param TESTVAR (if found) or add a new line just before the closing }

Result will be:

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME     $request_filename;
    fastcgi_read_timeout 1000;
fastcgi_param TESTVAR  testvar;
}

@mblaschke
Copy link
Member

go-replace 1.1.x is available with newest images :)

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

No branches or pull requests

3 participants