<VirtualHost *:441>
	ServerName plan.dev
	ServerAlias plan au.plan.dev us.plan.dev opal2.plan.dev
	DocumentRoot "/var/www/plan"
	ServerAdmin sam@plan.dev
	ErrorLog logs/plan-error_log
	CustomLog logs/plan-access_log combined
	ScriptAlias /x/ /var/www/plan/x/
	ScriptAlias /a/ /var/www/plan/a/
	AddHandler cgi-script .cgi
	<Directory "/var/www/plan">
		Options +Indexes
		Options +FollowSymLinks -SymLinksIfOwnerMatch
		Require all granted
		AllowOverride All
	</Directory>
	<Directory "/var/www/plan/x">
		AllowOverride None
		Options +ExecCGI -MultiViews
		Options +FollowSymLinks -SymLinksIfOwnerMatch
		Require all granted
	</Directory>
	<Directory "/var/www/plan/a">
		AllowOverride None
		Options +ExecCGI -MultiViews
		Options +FollowSymLinks -SymLinksIfOwnerMatch
		AuthName "Admin Only"
		AuthType Basic
		AuthUserFile /var/www/plan/.htpasswd
		Require valid-user
	</Directory>
	<Directory "/var/www/plan/logout">
		AllowOverride None
		authname "Admin Only"
		authtype basic
		authuserfile /var/www/plan/logout/.htpasswd
		require valid-user
	</Directory>
	<Directory "/var/www/plan/log">
		AllowOverride None
		authname "admin only"
		authtype basic
		authuserfile /var/www/plan/.htpasswd
		require valid-user
	</Directory>
	<FilesMatch "^\.">
		order allow,deny
		deny from all
	</FilesMatch>

	ProxyRequests Off
	ProxyPreserveHost On
	ProxyVia Full
	<Proxy *>
		Require all granted
	</Proxy>
	<Location /ssh/>
		ProxyPass http://127.0.0.1:2222/ssh/
		ProxyPassReverse http://127.0.0.1:2222/ssh/
	</Location>

	AddDefaultCharset utf-8
	RewriteEngine on
	RewriteRule ^/math/(.*)$ https://sam.try.coach/$1 [L]
	RewriteRule ^/d/(.*)$ https://dilbert.com/strips/comic/$1 [L]
#	RewriteRule ^/sam$ https://sam.aiki.info/ [L]
	SSLCertificateFile /etc/letsencrypt/live/plan.dev/fullchain.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/plan.dev/privkey.pem
	Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
<VirtualHost *:80>
	ServerName plan.dev
	ServerAlias plan au.plan.dev us.plan.dev opal2.plan.dev
	DocumentRoot "/var/www/plan"
	ServerAdmin sam@plan.dev
	ErrorLog logs/plan-error_log
	CustomLog logs/plan-access_log combined
	RewriteEngine on
	RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
</VirtualHost>
