Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to configure cdn with nginx for images. GeoIp is working fine, but i have a problem with images that are not found on cdn server.

I configured nginx the following way: Client requests the image from server1, server1 checks if the client is from "UK" is yes redirect to CDN server. but now lets say the image is not found on CDN server server how can i redirect back to server1 if CDN server is also from "UK". this will enter to endless loop...

share|improve this question

1 Answer 1

With a strategically-placed rewrite directive, you can append $uri with a parameter on the progress of redirects, and check for this parameter to decide whether or not to redirect back to CDN.

Or you could also use proxy_set_header directive when doing a request from the CDN back onto the main server1 site, and check for the existence of such HTTP header when processing requests on the main server1 site.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.