I would like Nginx to return actual files instead of response with Location:
redirect header. I use Nginx as a reverse proxy cache: cdn.mydomain.com
receives a request and contacts api.mydomain.com/files/
to fetch image files from there, but api.mydomain.com/files/
returns a blank response with Location:
redirect header to AWS S3, instead of a file itself.
Thus, Nginx caches the blank redirect response. How can I make Nginx to fetch and cache the actual file from 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";
}
}