Welcome! Log In Create A New Profile

Advanced

questions about $args on try_files inside location with regex

Posted by pepejose 
questions about $args on try_files inside location with regex
May 08, 2013 11:17AM
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;
> }

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



Edited 3 time(s). Last edit at 05/08/2013 11:20AM by pepejose.
Re: questions about $args on try_files inside location with regex
May 11, 2013 05:32AM
Hello,

Maybe you don't need PHP at all to resize images, as there is native nginx module that performs this job.

http://wiki.nginx.org/HttpImageFilterModule

It does all what you need and will put less strain on your server than the PHP backend mat have.

Andrejs
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 268
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready