Benny's Shopware Notebook
  • Introduction
    • How to Get in Touch
  • ddev for Shopware
    • Less than 5 Minutes Install with ddev and Symfony Flex
    • Storefront and Admin Watchers with ddev
    • Message Queue Setup with ddev
    • Contribute with ddev
    • Performance Tweaks
    • RabbitMQ with ddev
    • phpstan pro with ddev
    • Fetch Media from Production or Staging Server
  • Hosting
    • Setting up a Cloud Server with ddev
    • How to Trouble-shoot and Evaluate Environment Variables
    • Media URLs Out Of Sync between Servers
    • RabbitMQ
    • Running Shopware CE with PaaS
    • SFTP-Users
    • Basic-Auth for Shopware 6 with nginx
    • How to Avoid Failed Systemd Units
    • JWT-Secrets as Environment Variables
  • Deployment
    • Close-to-Zero Downtime Deployment
    • Docker-Images for Deployment with Gitlab-Runners
    • PHP Cache Related Issues
  • Development
    • Patching the Core
    • How to Discover Available Updates?
    • Local Testing of Shopware Commercial Features
  • Administration
  • Database
  • Migration
    • Side Effects
Powered by GitBook
On this page

Was this helpful?

  1. ddev for Shopware

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.

The following redirect or proxy directives will load all media and thumbnail files not available locally from a staging or production server.

When using apache (webserver-type: apache-fpm) add these lines at the beginning of your public/.htaccess file:

<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>

Do not commit this updated public/.htaccess file to your repo.

When using nginx (webserver-type: nginx-fpm), create a file .ddev/nginx/media-redirect.conf with the following contents (with optional basic auth):

    location @mediaserver {
        proxy_pass https://staging.example.com;
        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;
    }

The nginx way obviously has the advantage that it can be committed to your repository and, once setup, doesn't need any further attention.

Previousphpstan pro with ddevNextHosting

Last updated 28 days ago

Was this helpful?

Also see .

https://notebook.vanwittlaer.de/hosting/media-urls-out-of-sync-between-servers