Advice on max_ranges for specific location block

Hi,

Hopefully this question isn’t too basic, I just want to check if I’m
missing
something obvious.

I’m setting up a basic nginx installation with php-fpm behind it running
on
127.0.0.1:9000 - that’s working fine. I’m using max_ranges set to 5
globally in the server block (example below), but I have a specific PHP
script (/free.php) that I want max_ranges set to 0 for. I’m not sure
how to
achieve this.

max_ranges needs to be in a http, server or location block, so would the
best solution be to copy the “location ~ .php” block and call it
“location
~* /free.php” and just add the “max_ranges 0” setting in there? I was
hoping that location blocks cascade so I could overwrite that setting
and
then the request would fall into the .php block but I don’t think that’s
actually the case?

A basic example of what I’m currently using is:
server {
listen 80;
server_name localhost;
max_ranges 5;

    location / {
            root    /var/www/example.com;
            index   index.php;
    }

    location ~ \.php {
            set             $script         $uri;
            set             $path_info      "";

            if ($uri ~ "^(.+\.php)(/.*)") {
                    set             $script         $1;
                    set             $path_info      $2;
            }

            client_body_temp_path   /tmp 1;
            client_max_body_size    2048m;
            fastcgi_pass            127.0.0.1:9000;
            fastcgi_read_timeout    300;
            fastcgi_index           index.php;
            fastcgi_param           SCRIPT_FILENAME

/var/www/example.com$script;

            include /etc/nginx/fastcgi_params;
    }

}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,248175,248175#msg-248175

Hello!

On Thu, Mar 06, 2014 at 06:21:22AM -0500, sephreph wrote:

max_ranges needs to be in a http, server or location block, so would the
best solution be to copy the “location ~ .php” block and call it “location
~* /free.php” and just add the “max_ranges 0” setting in there? I was
hoping that location blocks cascade so I could overwrite that setting and
then the request would fall into the .php block but I don’t think that’s
actually the case?

Generally I would recommend adding a “location = /free.php” with
settings specific to a particular script.

On the other hand, in this case there is no real reason to do
anything as nginx won’t try to add ranges support for fastcgi
output. It’s up to your fastcgi script decide how to to handle
range requests.


Maxim D.
http://nginx.org/

Hi Maxim!

Maxim D. Wrote:


Maxim D.
http://nginx.org/


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

I’m using the XSendFile module too (I stripped that out of my example
for
brevity but maybe that was a poor idea). That’s why I was relying on
max_ranges, but I guess I could just check for a range request and
return a
416 through the PHP script if one’s requested? I’ll have to test to see
if
that works, but if it doesn’t I’ll just duplicate the existing location
block and make it specific to free.php, and add that setting.

Thanks!

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,248175,248204#msg-248204

Sorry to reply to my own post, but for anyone else who come across this,
it
looks like the easiest thing to do is to just add the max_ranges
directive
inside the location block containing the XSendFile alias - so in my
case, I
made the location that the free.php script uses different from the other
scripts and bam - success.

Thanks for all your Help Maxim!

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,248175,248205#msg-248205

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs