location ~* \.(ico|jpg|jpeg|png|gif|svg|webp|js|css|swf|eot|ttf|otf|woff|woff2|pdf)$ {
    # Proxying to AWS S3 storage.
    resolver 8.8.8.8;
    set $bucket "images.enterpriseapplicationdevelopers.com";
    proxy_pass https://s3.amazonaws.com/$bucket$uri;
    proxy_pass_request_body off;
    proxy_pass_request_headers off;
    proxy_intercept_errors on;
    proxy_hide_header "x-amz-id-2";
    proxy_hide_header "x-amz-request-id";
    proxy_hide_header "x-amz-storage-class";
    proxy_hide_header "Set-Cookie";
    proxy_ignore_headers "Set-Cookie";
}

location ^~ /media/ {
    resolver 8.8.8.8;
    set $s3_host "images.enterpriseapplicationdevelopers.com";
    proxy_pass https://$s3_host$request_uri;
    proxy_set_header Host $s3_host;

    proxy_pass_request_body off;
    proxy_pass_request_headers off;
    proxy_intercept_errors on;

    proxy_hide_header "x-amz-id-2";
    proxy_hide_header "x-amz-request-id";
    proxy_hide_header "x-amz-storage-class";
    proxy_hide_header "Set-Cookie";
    proxy_ignore_headers "Set-Cookie";
}

