Skip to content

Instantly share code, notes, and snippets.

@elieux
Created December 5, 2018 19:37

Revisions

  1. elieux created this gist Dec 5, 2018.
    21 changes: 21 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    FROM ubuntu:18.04

    COPY ./apt-wrapper.sh /tmp/apt
    RUN chmod +x /tmp/apt

    RUN /tmp/apt install -y --no-install-recommends apache2='2.4.*'

    RUN a2enmod rewrite
    RUN a2dissite 000-default

    RUN sed -e '/^*)/ { n; s/$HTTPD/exec &/; }' -i /usr/sbin/apache2ctl
    ENTRYPOINT [ "apache2ctl" ]
    CMD [ "-DFOREGROUND" ]
    EXPOSE 80

    COPY ./default.conf /etc/apache2/sites-available/default.conf
    RUN a2ensite default

    RUN rm /var/www/html/index.*
    COPY ./htaccess /var/www/html/.htaccess
    COPY ./*.html /var/www/html/
    10 changes: 10 additions & 0 deletions apt-wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #!/bin/sh
    set -e

    apt update
    DEBIAN_FRONTEND=noninteractive apt "$@"
    apt clean
    apt autoremove -y
    rm -rf /var/log/{alternatives.log,apt,dpkg.log}
    rm -rf /var/cache/apt
    rm -rf /var/lib/apt/lists
    13 changes: 13 additions & 0 deletions default.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <VirtualHost *:80 *:443>
    ServerName test
    DocumentRoot "/var/www/html"
    </VirtualHost>

    <Directory "/var/www/html/">
    Options FollowSymLinks
    AllowOverride All
    <FilesMatch "foo">
    RewriteEngine On
    RewriteRule .* - [F]
    </FilesMatch>
    </Directory>
    1 change: 1 addition & 0 deletions default.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    This is default.
    3 changes: 3 additions & 0 deletions htaccess
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    RewriteEngine on
    RewriteRule ^(foo|bar)$ /default.html [L]
    RewriteRule ^baz$ /foobar [L]
    3 changes: 3 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    <a href="bar">bar</a> - should work and does<br/>
    <a href="foo">foo</a> - should work, but doesn't<br/>
    <a href="baz">baz</a> - shouldn't work and doesn't<br/>