Replace all instances of ayotteconsulting.com with your domain
Current Status: Only one domain (AyotteConsulting-Production) is configured
ssh-keygen -R 3.148.89.12 # Clear old SSH cache if needed
ssh ubuntu@3.148.89.12 # Replace with actual IP of new server
sudo apt update
sudo apt upgrade -y
sudo apt autoremove --purge -y
sudo reboot
sudo apt install apache2 -y
sudo mkdir -p /var/www/ayotteconsulting.com
sudo chown -R ubuntu:www-data /var/www/ayotteconsulting.com
sudo chmod -R 755 /var/www/ayotteconsulting.com
Create file: sudo nano /var/www/ayotteconsulting.com/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ayotte Consulting - Test Page</title>
</head>
<body>
<h1>Ayotte Consulting Test Page</h1>
<p>If you see this page, the server is working!</p>
</body>
</html>
Create file: sudo nano /etc/apache2/sites-available/ayotteconsulting.com.conf
<VirtualHost *:80>
ServerName ayotteconsulting.com
ServerAlias www.ayotteconsulting.com
DocumentRoot /var/www/ayotteconsulting.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite ayotteconsulting.com.conf
sudo a2dissite 000-default.conf
sudo a2enmod headers
sudo systemctl reload apache2
Go to: http://[your IP] or http://ayotteconsulting.com
You should see your test page.
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d ayotteconsulting.com -d www.ayotteconsulting.com
sudo certbot renew --dry-run
Certbot will:
Go to: https://ayotteconsulting.com
Cert should be valid. Site should load.
Edit:
sudo nano /etc/apache2/sites-available/000-ayotteconsulting-le-ssl.conf
Replace the entire configuration block with the following:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName ayotteconsulting.com
ServerAlias www.ayotteconsulting.com
DocumentRoot /var/www/ayotteconsulting.com
# SSL Configuration
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/ayotteconsulting.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ayotteconsulting.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
# Security Headers
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Permissions-Policy "geolocation=(), microphone=()"
Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' https://*; font-src 'self' https://*; connect-src 'self'; object-src 'none';"
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</IfModule>
Then reload Apache:
sudo apachectl configtest
sudo systemctl reload apache2
sudo a2ensite 000-ayotteconsulting-le-ssl.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
Now, test https://ayotteconsulting.com in your browser to confirm that SSL is properly set up, and that the security headers are working as expected.
Run a security scan and see an A+ rating (Fingers Crossed)
Visit: Mozilla Observatory to test your site's security configuration.