<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div>My module (ngx_http_fastimg_module) rewrites the uri of an image request. If the image is not yet in the filesystem, then it (using try_files) calls a fastcgi  (fastimg_fcgi)  that creates the image, serves it, and saves it in the file system.<div class=""><br class=""></div><div class="">I have noticed something that I don’t understand. When the fastcgi program is executed, it receives the original uri in the REQUEST_URI fastcgi param, and not the rewritten uri.</div><div class=""><br class=""></div><div class="">I also notice that the rewritten uri is available in the DOCUMENT_URI fastcgi param.</div><div class=""><br class=""></div><div class="">Is this what you would expect?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Mark</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">See partial debug log below.</div><div class=""><br class=""></div><div class="">original uri: "/images/12/0/100/0.jpg”</div><div class="">rewritten uri:"/images/21/12_0_100_0.jpg”</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">—————</div><div class=""><br class=""></div><div class=""><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 0</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "/"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "images/"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 using configuration "/images/"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http cl:-1 max:104857600</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2</div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler</b></div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 ngx_http_fastimg_rewrite() uri in: "/images/12/0/100/0.jpg"</b></div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 ngx_http_fastimg_rewrite() uri out: "/images/21/12_0_100_0.jpg"</b></div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 internal redirect: "/images/21/12_0_100_0.jpg?"</b></div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 0</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "/"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "images/"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 using configuration "/images/"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http cl:-1 max:104857600</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 3</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 post rewrite phase: 4</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 5</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 6</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 7</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 8</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 post access phase: 9</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 10</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 try files handler</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 trying to use file: "/images/21/12_0_100_0.jpg" "/var/www/html/<a href="http://static.ranchmed.com/images/21/12_0_100_0.jpg" class="">static.ranchmed.com/images/21/12_0_100_0.jpg</a>"</div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 trying to use file: "@fastimg_fcgi" "/var/www/html/<a href="http://static.ranchmed.com" class="">static.ranchmed.com</a>@fastimg_fcgi"</b></div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "@fastimg_fcgi"</b></div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 using location: @fastimg_fcgi "/images/21/12_0_100_0.jpg?</b>"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 3</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 post rewrite phase: 4</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 5</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 6</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 7</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 8</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 post access phase: 9</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 10</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 11</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http init upstream, client timer: 0</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 epoll add event: fd:17 op:3 ev:80002005</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "QUERY_STRING"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "QUERY_STRING: "</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_METHOD"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "GET"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_METHOD: GET"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CONTENT_TYPE"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "CONTENT_TYPE: "</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CONTENT_LENGTH"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "CONTENT_LENGTH: "</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SCRIPT_NAME"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SCRIPT_NAME: /images/21/12_0_100_0.jpg"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_URI"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/12/0/100/0.jpg"</div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_URI: /images/12/0/100/0.jpg"</b></div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "DOCUMENT_URI"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg"</div><div class=""><b class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "DOCUMENT_URI: /images/21/12_0_100_0.jpg"</b></div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "DOCUMENT_ROOT"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/var/www/html/<a href="http://static.ranchmed.com" class="">static.ranchmed.com</a>"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "DOCUMENT_ROOT: /var/www/html/<a href="http://static.ranchmed.com" class="">static.ranchmed.com</a>"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_PROTOCOL"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "HTTP/1.0"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_PROTOCOL: HTTP/1.0"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_SCHEME"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "http"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_SCHEME: http"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: ""</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "GATEWAY_INTERFACE"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CGI/1.1"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "GATEWAY_INTERFACE: CGI/1.1"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_SOFTWARE"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "nginx/"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "1.15.7"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_SOFTWARE: nginx/1.15.7"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REMOTE_ADDR"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "192.168.1.1"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REMOTE_ADDR: 192.168.1.1"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REMOTE_PORT"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "42034"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REMOTE_PORT: 42034"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_ADDR"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "192.168.1.101"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_ADDR: 192.168.1.101"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_PORT"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "80"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_PORT: 80"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_NAME"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "<a href="http://dev.static.ranchmed.com" class="">dev.static.ranchmed.com</a>"</div><div class="">2019/01/09 14:33:29 [debug] 19835#0: accept() not ready (11: Resource temporarily unavailable)</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_NAME: <a href="http://dev.static.ranchmed.com" class="">dev.static.ranchmed.com</a>"</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REDIRECT_STATUS"</div><div class="">2019/01/09 14:33:29 [debug] 19835#0: timer delta: 22583</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "200"</div><div class="">2019/01/09 14:33:29 [debug] 19835#0: worker cycle</div><div class="">2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REDIRECT_STATUS: 200"</div></div></body></html>