Skip to content

Instantly share code, notes, and snippets.

@sean-e-dietrich
Created March 11, 2019 14:01
Show Gist options
  • Save sean-e-dietrich/c3569287fc923d5014a0e8feab56060a to your computer and use it in GitHub Desktop.
Save sean-e-dietrich/c3569287fc923d5014a0e8feab56060a to your computer and use it in GitHub Desktop.
Docksal File Proxy for Drupal
# Should be placed in .docksal/docksal-local.env
# Change URL to location of files
APACHE_FILE_PROXY="http://www.example.com"
# Should be placed in .docksal/dockal-local.yml
version: "2.1"
services:
web:
environment:
- APACHE_FILE_PROXY
# Should be placed in .docksal/etc/apache/httpd-vhost-overrides.conf
<IfModule mod_rewrite.c>
RewriteEngine on
# Force image styles that have local files that exist to be generated.
RewriteCond %{REQUEST_URI} ^/sites/([^\/]*)/files/styles/[^\/]*/public/((.*))$
RewriteCond %{DOCUMENT_ROOT}/sites/%1/files/%2 -f
RewriteRule ^(.*)$ $1 [QSA,L]
# Otherwise, send anything else that's in the files directory to the
# production server.
RewriteCond %{ENV:APACHE_FILE_PROXY} !^$
RewriteCond %{REQUEST_URI} ^/sites/[^\/]*/files/.*$
RewriteCond %{REQUEST_URI} !^/sites/[^\/]*/files/css/.*$
RewriteCond %{REQUEST_URI} !^/sites/[^\/]*/files/js/.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ %{ENV:APACHE_FILE_PROXY}/$1 [P,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment