Best way to redirect non-CloudFront requests to CloudFront

WheresWardy nginx-forum at nginx.us
Tue May 8 09:53:24 UTC 2012


OK, in the end I went with:

if ($http_user_agent !~ "Amazon CloudFront") {
    rewrite ^/(.*).(png|gif|jpg) http://abc.cloudfront.net/$1.$2
}

which seems to do the trick. Seems like there should be a better way of
doing what must be quite a common form of rewrite though? (Or is this
the fast alternative to Apache's REWRITE_COND?)

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,226015,226168#msg-226168



More information about the nginx mailing list