Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

questions about $args on try_files inside location with regex

$
0
0
hi! (sorry for my bad english)

i have a URL like this:

http://www.domain.com/resize.php?pic=images/elements/imagename.jpg&type=300crop

that php checks if that image exists and serves, if not, creates image on disk with the size specified in the type parameter and returns it.

what I wanted is to check if the image exists on disk at that size, with nginx, so run only resize.php when necessary to create the image.

I tried this, but i think that location directive doesn't operate on query parameters ($args) using regex, then loncation does not match with sample URL :(

any help please?

I need to rewrite the parameters ($args) and use them in the try_files directive... is this possible?

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

> location ~ "^/resize\.php\?pic=images/(elements|gallery)/(.*)\.jpg&type=([0-9]{1,3}[a-z]{0,4})$)"{
> try_files /images/$1/$2.jpg /imagenes/elements/thumbs/$3_$2.jpg @phpresize;
> }

> location @phpresize {
> try_files $uri =404;
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_buffering on;
> proxy_pass http://127.0.0.1:8080;
> }

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>