Specify setting for nginx location

Hi. I want to specify settings only 1 url to uploading big files. Like for domain.com/api/v1/customer/upload i need to set for nginx: clientmaxbodysize 100m; clientbody_timeout 600;

and for php: uploadmaxfilesize = 100M postmaxsize = 100M

How can i do that?



7.2k

Because NGINX use PHP via PHP-FPM instead php5_module of Apache, you can't set any php directives in server.

You can use ini_set function in your application



1.3k

uploadmaxfilesize and postmaxsize cant be setted via ini_set

Because NGINX use PHP via PHP-FPM instead php5_module of Apache, you can't set any php directives in server.

You can use ini_set function in your application

php-fpm.conf add the following lines (and modify if needed):

php_admin_value[upload_max_filesize] = 20M
php_admin_value[max_file_uploads] = 20
php_admin_value[post_max_size] = 24M

Add the line to nginx.xonf:

client_max_body_size 20m;


1.3k

i need this settings only for 1 path - /api/v1/customer/upload, for other paths i want to use defaults

php-fpm.conf add the following lines (and modify if needed):

``` phpadminvalue[uploadmaxfilesize] = 20M phpadminvalue[maxfileuploads] = 20 phpadminvalue[postmaxsize] = 24M ```

Add the line to nginx.xonf:

``` clientmaxbody_size 20m; ```



7.2k

uploadmaxfilesize and postmaxsize cant be setted via ini_set

Because NGINX use PHP via PHP-FPM instead php5_module of Apache, you can't set any php directives in server.

You can use ini_set function in your application

Yes. I agree. Taking off my hat :)

But settings in php-fpm conf is general set.

I use chunked upload.

In my PHP I have 20M limit, but with chunked upload I have no limit for upload file size.

The logic is simple.

You split file to chunkes of 10 or more Mb (as need) and on server just merge chunks and restore file.

Advantage - high speed of upload



1.3k
edited Feb '16

Isn't it pain in ass for netbooks? I mean file got chunked by javascript on frontend, yes? So will 100mb files cause bad expirience on low pc? And btw, how i can set limit like 100 mb on backend for that kind of uploading?

uploadmaxfilesize and postmaxsize cant be setted via ini_set

Because NGINX use PHP via PHP-FPM instead php5_module of Apache, you can't set any php directives in server.

You can use ini_set function in your application

Yes. I agree. Taking off my hat :)

But settings in php-fpm conf is general set.

I use chunked upload.

In my PHP I have 20M limit, but with chunked upload I have no limit for upload file size.

The logic is simple.

You split file to chunkes of 10 or more Mb (as need) and on server just merge chunks and restore file.

Advantage - high speed of upload



7.2k

Isn't it pain in ass for netbooks? I mean file got chunked by javascript on frontend, yes? So will 100mb files cause bad expirience on low pc? And btw, how i can set limit like 100 mb on backend for that kind of uploading?

uploadmaxfilesize and postmaxsize cant be setted via ini_set

Because NGINX use PHP via PHP-FPM instead php5_module of Apache, you can't set any php directives in server.

You can use ini_set function in your application

Yes. I agree. Taking off my hat :)

But settings in php-fpm conf is general set.

I use chunked upload.

In my PHP I have 20M limit, but with chunked upload I have no limit for upload file size.

The logic is simple.

You split file to chunkes of 10 or more Mb (as need) and on server just merge chunks and restore file.

Advantage - high speed of upload

Load capacity is not changed. Of course, you can set any limit of upload