How to tell Proxy module to retrieve secondary URL if primary URL doenst exist

Maxim Dounin mdounin at mdounin.ru
Thu Oct 4 09:45:44 UTC 2012


Hello!

On Wed, Oct 03, 2012 at 05:00:39PM -0400, wurb32 wrote:

> Hi all,
> 
> I am using nginx's Proxy module to retrieve images from Amazon S3. I need to
> be able to tell the Proxy module to retrieve a smaller sized file if a
> bigger sized file doesnt exist. How can I do that? 
> 
> For instance, my nginx configuration:
> 
> 	location / {
>             proxy_pass   https://s3.amazonaws.com/my_bucket/;
>             error_page   415 = /empty;
> 	}
> 
> Say I have image1_100.jpg on S3 then http://localhost/image1_100.jpg works
> fine. However http://localhost/image1_300.jpg wont work. I want to be able
> to ask nginx to request the 
> https://s3.amazonaws.com/my_bucket/image1_300.jpg file and if it doesnt
> exist, request for iamge1_100.jpg file instead.

Use error_page 404 and proxy_intercept_errors, see 
http://nginx.org/r/proxy_intercept_errors.

-- 
Maxim Dounin
http://nginx.com/support.html



More information about the nginx mailing list