Skip to content

Instantly share code, notes, and snippets.

@elieux
Created December 5, 2018 19:37
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 elieux/08fdfd299b84153b6eec4ea535ab81bc to your computer and use it in GitHub Desktop.
Save elieux/08fdfd299b84153b6eec4ea535ab81bc to your computer and use it in GitHub Desktop.
Why does HTTPd do this?
#!/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
<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>
This is default.
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/
RewriteEngine on
RewriteRule ^(foo|bar)$ /default.html [L]
RewriteRule ^baz$ /foobar [L]
<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/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment