<VirtualHost *:80>
	ServerAdmin webmaster@minmaxiste.com
	ServerName <%= @name %>
	ServerAlias <%= @name %> <%= @aliases.join(' ') %>

	DocumentRoot <%= @docroot %>
	RedirectMatch permanent "^(?!/.well-known/acme-challenge/.*)" https://<%= @name %>/$1

	ErrorLog ${APACHE_LOG_DIR}/<%= @name %>/error.log
	CustomLog ${APACHE_LOG_DIR}/<%= @name %>/access.log combined
</VirtualHost>

<VirtualHost *:442>
	ServerAdmin webmaster@minmaxiste.com
	ServerName <%= @name %>
	ServerAlias <%= @name %> <%= @aliases.join(' ') %>

	DocumentRoot <%= @docroot %>
	DirectoryIndex index.md index.html

	AddDefaultCharset UTF-8
	AddCharset UTF-8 .md

	ErrorLog ${APACHE_LOG_DIR}/<%= @name %>/error.log
	CustomLog ${APACHE_LOG_DIR}/<%= @name %>/access.log combined

	RemoteIPProxyProtocol On

	SSLEngine on
	SSLCertificateFile      /etc/ssl/certs/<%= @fqdn %>.pem
	SSLCertificateKeyFile   /etc/ssl/private/<%= @fqdn %>.pem

	<FilesMatch "\.(?:cgi|shtml|phtml|php)$">
		SSLOptions +StdEnvVars
	</FilesMatch>
	<Directory /usr/lib/cgi-bin>
		SSLOptions +StdEnvVars
	</Directory>

	Alias /md.css /var/www/md.css
	ExtFilterDefine md-to-html mode=output \
		intype=text/markdown outtype=text/html \
		cmd="/usr/bin/pandoc \
		--template=/var/www/md-to-html-template.html \
		--to=html --standalone"
	<FilesMatch ".+\.md(\.(en|fr))?$">
		SetOutputFilter md-to-html
	</FilesMatch>

	AddLanguage fr-CA .fr
	<Directory <%= @docroot %>>
		Options <%= @docroot_options.join(' ') %>
	</Directory>
</VirtualHost>
