I would like Nginx to return the actual files instead of a response with the Location: redirect header. I use Nginx as a reverse proxy cache: cdn.mydomain.com receives a request and contacts api.mydomain.com/files/ to retrieve image files from there, but api.mydomain.com/files/ returns an empty response with Location: redirect header on AWS S3 instead of the file itself.
Thus, Nginx caches an empty redirect response. How can I get Nginx to retrieve and cache the actual file with S3.
user www-data; worker_processes 4; pid /var/run/nginx.pid; http { server_names_hash_bucket_size 64; proxy_redirect off; proxy_cache_path /var/cache/nginx levels=2:2:2 keys_zone=my-cache:8m max_size=4G inactive=600m; proxy_temp_path /var/cache/tmp; server { listen 80; server_name cdn.mydomain.com; server_tokens off; location / { proxy_pass http://api.mydomain.com/files/; proxy_cache my-cache; proxy_cache_valid 200 302 30d; expires 30d; add_header Pragma public; add_header Cache-Control "public"; } }
source share