berberapa langkah kita untuk menginstal ssl dan membuat halaman otomatis redirect ke https
- mengaktifkan modul ssl
- mengaktifkan modeul rewrite
- melakukan konfigurasi kunci privat dan sertifikat SSL lokasi .crt dan .key
- file default.conf untuk virtualhost 80 (non https) dan file default-ssl.conf (untuk file https)
aktifkan ssl
a2enmod ssl kemudian restart apache systemctl restart apache2</pre> <pre>
lihat apakah ssl sudah aktif dengan
nmap localhost (jika belom ada install nmap dulu) jika ada 443/tcp brati sudah aktif
aktifkan mod rewrite
a2enmod rewrite lakukan restart service apache systemctl restart apache2
ubah konfigurasi ssl disini saya menggunakan file default-ssl.conf
ingat yang diedit ada di sites-available bukan di sites-enabled
nano /etc/apache2/sites-available/default-ssl.conf edit ini SSLCertificateFile alamatkunci.crt SSLCertificateKeyFile alamatprivate.key
ubahkonfigurasi virtualhost untuk port 80 agar jika membuka tanpa https langsung ke redirect ke https pada file default.conf
nano /etc/apache2/sites-available/default-ssl.conf tambahkan ini ServerName www.alamatserver.com RewriteEngine On RewriteCond %{HTTP_HOST} ^alamatserver.com RewriteCond %{HTTPS} !=on RewriteRule (.*) https://alamatserver.com$1 [R=301,L] aktifkan https dengan a2ensite default-ssl.conf untuk check konfigurasi virtual host yang aktif dengan cara apache2ctl -S
semoga berguna 🙂
- https://www.namecheap.com/support/knowledgebase/article.aspx/9821/38/redirect-to-https-on-apache
- https://serverfault.com/questions/746875/how-to-make-apache-s-mod-rewrite-redirect-over-https-by-default
- https://stackoverflow.com/questions/869092/how-to-enable-mod-rewrite-for-apache-2-2
- https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-16-04
- https://snipplr.com/view/15626/apache2–enabling-and-disabling-sites/
- https://stackoverflow.com/questions/21812360/what-is-the-difference-between-sites-enabled-and-sites-available-directory
- https://www.faqforge.com/linux/controlpanels/get-a-list-of-all-virtual-hosts-which-are-defined-in-all-apache-configuration-files/
tinggalkan pesan