Welcome! Log In Create A New Profile

Advanced

Confusion about rewritten uri passed to a fastcgi program

Mark Sellers
January 09, 2019 06:06PM
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.

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.

I also notice that the rewritten uri is available in the DOCUMENT_URI fastcgi param.

Is this what you would expect?

Thanks,
Mark


See partial debug log below.

original uri: "/images/12/0/100/0.jpg”
rewritten uri:"/images/21/12_0_100_0.jpg”


—————

2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 0
2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "/"
2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "images/"
2019/01/09 14:33:29 [debug] 19834#0: *1 using configuration "/images/"
2019/01/09 14:33:29 [debug] 19834#0: *1 http cl:-1 max:104857600
2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2
2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler
2019/01/09 14:33:29 [debug] 19834#0: *1 ngx_http_fastimg_rewrite() uri in: "/images/12/0/100/0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 ngx_http_fastimg_rewrite() uri out: "/images/21/12_0_100_0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 internal redirect: "/images/21/12_0_100_0.jpg?"
2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 0
2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "/"
2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "images/"
2019/01/09 14:33:29 [debug] 19834#0: *1 using configuration "/images/"
2019/01/09 14:33:29 [debug] 19834#0: *1 http cl:-1 max:104857600
2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2
2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler
2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 3
2019/01/09 14:33:29 [debug] 19834#0: *1 post rewrite phase: 4
2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 5
2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 6
2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 7
2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 8
2019/01/09 14:33:29 [debug] 19834#0: *1 post access phase: 9
2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 10
2019/01/09 14:33:29 [debug] 19834#0: *1 try files handler
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 trying to use file: "/images/21/12_0_100_0.jpg" "/var/www/html/static.ranchmed.com/images/21/12_0_100_0.jpg http://static.ranchmed.com/images/21/12_0_100_0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 trying to use file: "@fastimg_fcgi" "/var/www/html/static.ranchmed.com http://static.ranchmed.com/@fastimg_fcgi"
2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "@fastimg_fcgi"
2019/01/09 14:33:29 [debug] 19834#0: *1 using location: @fastimg_fcgi "/images/21/12_0_100_0.jpg?"
2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2
2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler
2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 3
2019/01/09 14:33:29 [debug] 19834#0: *1 post rewrite phase: 4
2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 5
2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 6
2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 7
2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 8
2019/01/09 14:33:29 [debug] 19834#0: *1 post access phase: 9
2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 10
2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 11
2019/01/09 14:33:29 [debug] 19834#0: *1 http init upstream, client timer: 0
2019/01/09 14:33:29 [debug] 19834#0: *1 epoll add event: fd:17 op:3 ev:80002005
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "QUERY_STRING"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "QUERY_STRING: "
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_METHOD"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "GET"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_METHOD: GET"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CONTENT_TYPE"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "CONTENT_TYPE: "
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CONTENT_LENGTH"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "CONTENT_LENGTH: "
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SCRIPT_NAME"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SCRIPT_NAME: /images/21/12_0_100_0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_URI"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/12/0/100/0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_URI: /images/12/0/100/0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "DOCUMENT_URI"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "DOCUMENT_URI: /images/21/12_0_100_0.jpg"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "DOCUMENT_ROOT"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/var/www/html/static.ranchmed.com http://static.ranchmed.com/"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "DOCUMENT_ROOT: /var/www/html/static.ranchmed.com http://static.ranchmed.com/"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_PROTOCOL"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "HTTP/1.0"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_PROTOCOL: HTTP/1.0"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_SCHEME"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "http"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_SCHEME: http"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: ""
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "GATEWAY_INTERFACE"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CGI/1.1"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "GATEWAY_INTERFACE: CGI/1.1"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_SOFTWARE"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "nginx/"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "1.15.7"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_SOFTWARE: nginx/1.15.7"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REMOTE_ADDR"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "192.168.1.1"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REMOTE_ADDR: 192.168.1.1"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REMOTE_PORT"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "42034"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REMOTE_PORT: 42034"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_ADDR"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "192.168.1.101"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_ADDR: 192.168.1.101"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_PORT"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "80"
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_PORT: 80"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_NAME"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "dev.static.ranchmed.com http://dev.static.ranchmed.com/"
2019/01/09 14:33:29 [debug] 19835#0: accept() not ready (11: Resource temporarily unavailable)
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_NAME: dev.static.ranchmed.com http://dev.static.ranchmed.com/"
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REDIRECT_STATUS"
2019/01/09 14:33:29 [debug] 19835#0: timer delta: 22583
2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "200"
2019/01/09 14:33:29 [debug] 19835#0: worker cycle
2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REDIRECT_STATUS: 200"_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Confusion about rewritten uri passed to a fastcgi program

Mark Sellers 95 January 09, 2019 06:06PM

Re: Confusion about rewritten uri passed to a fastcgi program

Maxim Dounin 41 January 10, 2019 08:20AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 83
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready