Opened 4 years ago

Last modified 4 years ago

#752 accepted defect

try_files + subrequest + proxy-handler problem

Reported by: openid.yandex.ru/emychlo Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.7.x
Keywords: try_files Cc:
uname -a: Darwin myc.rutube.corp 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
nginx -V: nginx version: nginx/1.7.12 built by clang 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn) configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include -g -DNGX_DEBUG_MALLOC -O0' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/tmp/nginx.pid --error-log-path=/tmp/nginx-error.log --with-http_addition_module --with-debug --http-client-body-temp-path=/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/tmp/nginx/proxy_temp --http-scgi-temp-path=/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/tmp/nginx/uwsgi_temp --http-log-path=/tmp/nginx-access.log

Description (last modified by mdounin)

When using subrequests with try_files the following behaviour is observed.

   server {
       listen       8081;
       default_type text/html;

       location /uno {   return 200 "uno  ";   }
       location /duo {   return 200 "duo  ";   }
       location /tres {  return 200 "tres  ";  }
   }


   server {
       listen       8080;

       location / {
           root /tmp;
           try_files /tres =404;
           proxy_pass http://127.0.0.1:8081;
           add_after_body /duo;
       }
   }

Assuming /tmp/tres exists, a request to

http://127.0.0.1:8080/uno

returns "uno tres ", not "uno duo " or "tres tres ".

I.e., main request assumes that the request URI is unmodified and passes original request URI, "/uno".
But in a subrequest the URI is modified and nginx uses modified URI, "/tres".

This is believed to be a bug, and one of the following should be done:

  • try_files should reset the r->valid_unparsed_uri flag if it modifies the URI;
  • or try_files should not modify the URI at all.

See this thread (in Russian) for additional details.

Change History (1)

comment:1 Changed 4 years ago by mdounin

  • Description modified (diff)
  • Keywords try_files added
  • Status changed from new to accepted

Thanks for filing the ticket. I've translated it to English (and slightly modified to add some more details).

Note: See TracTickets for help on using tickets.