Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For some reason our website has one .jsphp file that needs to be handed to the PHP-FPM.

However, access will be denied because by default PHP-FPM only allows an extension of .php.

This can be solved by adding the following to php-fpm.conf

security.limit_extensions = .php .jsphp

But I only want to do this for a particular server location in the Nginx configuration, which is shown below

location ~ (\.php|\.jsphp)$ {
    try_files $uri = 404;
    include /usr/local/etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9001; # 9000 for xdebug
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PHP_VALUE "error_log=/usr/local/var/log/our-website.local-error.log";
}

Is it possible to add the PHP-FPM setting security.limit_extensions per server location? And if so, how do I do it?

Thanks!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I don't think it's possible to do exactly what you're asking for. The PHP-FPM config file doesn't support dynamic variables in it - everything is configured once to a set value and then the PHP-FPM pool is created with those values set.

However there are a couple of ways of solving your problem.

  1. Create a new PHP-FPM pool and have it listen on a different socket.

    i.e. copy your existing pool in your php-fpm.conf file, change the socket that it's listening on to 9002 and change the value of security.limit_extensions for just that pool. Then in your nginx config have files that have a .jsphp extension be sent to that new pool.

  2. Rename the file to be .js.php which is (imho) a better way of chaining extension types as it allows code editors to know that it is a PHP file without having to setup custom extensions in everyones editor.
    It then has a standard php extension and you don't need to worry about separate config for it.

share|improve this answer
    
Thanks for the suggestions. I will talk to whoever created the .jsphp file. –  hobbes3 May 5 '13 at 6:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.