#980 closed defect (invalid)

Root in Location is ignored for .gif files but accepted with php

Reported by: obble.smith@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.10.x
Keywords: Cc:
Sensitive: no
uname -a: Linux debian 4.5.0-x86_64-linode65 #2 SMP Mon Mar 14 18:01:58 EDT 2016 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.10.0 built with OpenSSL 1.0.2g 1 Mar 2016 (running with OpenSSL 1.0.2h 3 May 2016) TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --add-dynamic-module=/build/nginx-1.10.0/debian/modules/nginx-auth-pam --add-module=/build/nginx-1.10.0/debian/modules/nginx-dav-ext-module --add-module=/build/nginx-1.10.0/debian/modules/nginx-echo --add-module=/build/nginx-1.10.0/debian/modules/nginx-upstream-fair --add-module=/build/nginx-1.10.0/debian/modules/ngx_http_substitutions_filter_module

Description

I noticed that root directive inside a location is ignored for files.
a working conf.

server {
   root /var/www/plugin/;
   location /phpMyAdmin/ {
      root /var/www/plugins/;

      # Normal PHP scripts
      location ~ \.php$ {
          include fastcgi_params;
          fastcgi_pass php_workers;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
   }
}

With that configuration:

but if the server root is changed:

server {
   root /var/www/SOME_WHERE_ELSE/;       #somewhere else
   location /phpMyAdmin/ {
      root /var/www/plugins/;            #No effect on files

      # Normal PHP scripts
      location ~ \.php$ {
          include fastcgi_params;
          fastcgi_pass php_workers;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
   }
}

With that configuration:

so when serving a file, the location's root is ignored. (also same if root is in location /{})

Change History (3)

comment:1 Changed 17 months ago by mdounin

Most likely your problem is that requests to .gif files are handled elsewhere - in a regex location for static content or something like this you've omitted in the configuration snippet provided.

If you see the behaviour in question with the exact configuration you've provided - please provide debugging log and full configuration.

comment:2 Changed 17 months ago by obble.smith@…

You are correct MDounin,

This location inside of / intercepts the requests.

        location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
            expires max;
            log_not_found off;
            ## No need to bleed constant updates. Send the all shebang in one
            ## fell swoop.
            tcp_nodelay off;
            ## Set the OS file cache.
            open_file_cache max=1000 inactive=120s;
            open_file_cache_valid 45s;
            open_file_cache_min_uses 2;
            open_file_cache_errors off;
        }

thank you MDounin for correcting my understanding.

As there are no bug in nginx, (just an ignorant user), this bug report can be closed.

Cheers

comment:3 Changed 17 months ago by mdounin

  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.