Skip to content

Instantly share code, notes, and snippets.

@hakre
Created October 23, 2019 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakre/20cfe525fe927af00ab6b1e895fa8acc to your computer and use it in GitHub Desktop.
Save hakre/20cfe525fe927af00ab6b1e895fa8acc to your computer and use it in GitHub Desktop.
Docker Run without "docker run"
<<'EOD' docker build --rm --tag rewrite-tester --no-cache -
FROM httpd:alpine
RUN set -e \
; sed -i -e 's/^#LoadModule rewrite_module/LoadModule rewrite_module/' \
-e 's/^LogLevel .*$/LogLevel debug rewrite:trace8/' \
-e '\|<Directory "/usr/local/apache2/htdocs">|,\ </Directory> s/^ AllowOverride .*$/ AllowOverride All/' \
/usr/local/apache2/conf/httpd.conf \
; echo -e ' \n\
RewriteEngine On \n\
RewriteBase / \n\
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ \n\
RewriteRule ^(.*)$ $1?i=jplx [DPI,QSA] \n\
RewriteCond %{REQUEST_URI} !^/sites/default/files/js/ \n\
RewriteCond %{REQUEST_URI} !^/sites/default/files/css/ \n\
RewriteRule ^sites/default/files/(.*)$ index.php?q=system/files/$1 [END,QSA,R] \n\
' | tee /usr/local/apache2/htdocs/.htaccess \
; httpd-foreground & sleep 1 \
; apk add curl \
; curl -I 'http://127.0.0.1/sites/default/files/Slide074.png?abc' \
; exit 123
EOD
;: https://stackoverflow.com/a/58527089/367456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment