Fetch Media from Production or Staging Server
For local development and testing you do not have to copy all media files to your local environment.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(media|thumbnail)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ https://staging.example.com/$1 [L,R=301]
</IfModule> set $media_proxy_url "https://staging.example.com";
location @mediaserver {
resolver 1.1.1.1;
proxy_pass $media_proxy_url$request_uri;
proxy_set_header Authorization "Basic your-basic-auth-secret";
}
location ^~ /media/ {
access_log off;
expires max;
try_files $uri $uri/ @mediaserver;
break;
}
location ^~ /thumbnail/ {
access_log off;
expires max;
try_files $uri $uri/ @mediaserver;
break;
}Last updated