Shikachu
Shikachu

Reputation: 13

php-fpm and nginx image and css serving in a multi container setup

So we are currently working on a 1 webserver multiple PHP-FPM setup in Docker-Compose locally and Docker-Swarm on prod., and we started to feel like the job is done then we run into some issues with php-fpm when we wanted to load some image we got:

NOTICE: Access to the script '/app/DSDPersonnel/test.jpg' has been denied (see security.limit_extensions)

Then I started googling around and found out it's a php fpm error in www.conf or php-fpm.conf, so I tried to edit those.

Since we running this setup on docker I tried the following solutions:

ERROR: Passing INI directive through FastCGI: unable to set 'security.limit_extensions'

and then after page loading got the same:

NOTICE: Access to the script '/app/DSDPersonnel/test.jpg' has been denied (see security.limit_extensions)

Now I am completely out of ideas. Here is our nginx conf:

location /DSDPersonnel {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass dsd-personnel:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Any suggestion is useful but we don't want to move the images from the php container to the nginx because of the multiple container setup.

Upvotes: 1

Views: 2202

Answers (1)

Chakiral
Chakiral

Reputation: 46

Editing www.conf should do the trick I tested it right now on php-fpm 7, uncomment the line

security.limit_extensions = .php .php3 .php4 .php5

and add it the .jpg extension security.limit_extensions = .php .php3 .php4 .php5 .jpg

or uncomment it, and remove any extension in your dockerfile (beware of security risk):

RUN echo "security.limit.extensions =" >> /usr/local/etc/php-fpm.d/www.conf

(be careful of your www.conf location, and the >> that will append to file, instead of completely overwriting it)

Upvotes: 3

Related Questions