Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .