Repository navigation
Web Server and HTTPS
This page publishes KeyAnyWhere on your domain with Apache: a site that serves only the webroot/ folder, and a free HTTPS certificate from Let's Encrypt. HTTPS is not optional: with debug off, KeyAnyWhere refuses plain HTTP, and its session cookie only travels over HTTPS.
- The steps up to the Insecure Password Catalog are done.
- Your domain already points to this server (DNS), and ports 80 and 443 are open: Let's Encrypt checks the domain over port 80.
Set your domain once for the blocks below:
KAW_DOMAIN=kaw.example.comOnly webroot/ is public: the rest of the project (configuration, code, logs) stays out of reach of the browser. AllowOverride All lets the webroot/.htaccess file route every URL to KeyAnyWhere.
sudo tee /etc/apache2/sites-available/keyanywhere.conf > /dev/null <<EOF
<VirtualHost *:80>
ServerName $KAW_DOMAIN
DocumentRoot /var/www/keyanywhere/webroot
<Directory /var/www/keyanywhere/webroot>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog \${APACHE_LOG_DIR}/keyanywhere-error.log
CustomLog \${APACHE_LOG_DIR}/keyanywhere-access.log combined
</VirtualHost>
EOFTurn on the new site and turn off the Debian placeholder page:
sudo a2ensite keyanywhere && sudo a2dissite 000-defaultsudo apache2ctl configtestThe last command should print Syntax OK.
sudo systemctl reload apache2Certbot asks Let's Encrypt for a certificate, creates the HTTPS version of the site, redirects HTTP to HTTPS, and renews the certificate on its own before it expires.
sudo apt install -y certbot python3-certbot-apachesudo certbot --apache --redirect -d "$KAW_DOMAIN"Certbot asks for an e-mail (for expiry warnings) and for your agreement with the terms. Check that automatic renewal works:
sudo certbot renew --dry-runTip
More detail on Apache and certificates is in the posts Instalando o Apache2 e configurando SSL/TLS (in Portuguese).
The HTTP address must redirect to HTTPS, and the HTTPS address must answer through KeyAnyWhere. As no user exists yet, the login page sends you to the first-run setup.
curl -sI "http://$KAW_DOMAIN/" | head -n 1curl -s -o /dev/null -D - "https://$KAW_DOMAIN/users/login" | grep -iE '^(HTTP|location|strict-transport-security)'The first answer is HTTP/1.1 301 Moved Permanently. The second is:
HTTP/1.1 302 Found
Location: https://kaw.example.com/users/config-inicial
strict-transport-security: max-age=31536000; includeSubDomains; preload
Source code · Issues · Releases · Packagist · Online demo · Hosted edition
1. Getting started
2. Installing in production
- Overview
- Preparing the Server
- Installing KeyAnyWhere
- File Permissions
- Generating Security Keys
- Environment Variables
- Configuration Files
- Database Setup
- Insecure Password Catalog
- Web Server and HTTPS
- First-Run Setup
3. Operating your installation
4. Using KeyAnyWhere
5. Security
6. Development
7. Extending