Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Fega Suseno
Fega Suseno

Posted on

     

Publish HTTPS Local Server Using Cloudflare

hallo world!
Postingan kali ini akan membahas sedikit studi kasus, kita akan membuat server lokal kita agar bisa di akses online. Kali ini kita akan hubungkannya dengancloudflare.

Kenapa cloudflare?
Karena Cloudflare memiliki fiturCDN (Content Delivery Network) dan jugaDDOS Protection, sehingga membuat website lebih aman.

Kita akan langsung ke lab, berikut ini gambaran topologinya

Image description

Sedikit saya jelaskan Topologinya, jadi pada gambar di atas saya punya server local, router dengan Public Static IP, domainnzucode.store (berlangganan pada provider) dan akun cloudflare.

  • Step 1: Pointing Domain ke Cloudflare

Pertama kita perlu melakukan forwarding port 80 dan 443 pada router, ini bertujuan agar server lokal kita bisa di ekspose keluar, pada kasus saya menggunakan mikrotik.

Image description

Pada cloudflare kita copy pada bagian nameserver

Image description
Ini nantinya akan kita arahkan untuk nameserver domain kita. Untuk caranya berbeda-beda tergantung provider domain yg kita pakai, disini saya menggunakan rumahweb sebagai providernya. Kurang lebih seperti ini caranyahttps://www.rumahweb.com/journal/cara-setting-domain-di-cloudflare/

  • Step 2: Konfigurasi SSL Certificate

Kita akan membuat certificate SLL pada cloudflare, Certificate ini yg nantinya akan kita pasang pada sisi server local. Pastikan untuk mengcopy dan menyimpanya, karena certificate.pem hanya bisa dilihat satu kali.

Image description

Pastikan juga untuk enable beberapa opsi berikut

Image description

Image description

  • Step 3: Install Certificate Pada Local Server

Pertama buat config file di/etc/apache2/sites-available
untuk nama confignya misalnzucode.com.conf, Untuk referensi kita bisa copy juga daridefault-ssl.conf, tapi nantiperlu ada yg di ubah. Contoh konfignya saya cantumkan berikut:

<VirtualHost *:443>        DocumentRoot /var/www/html        ErrorLog ${APACHE_LOG_DIR}/error.log        CustomLog ${APACHE_LOG_DIR}/access.log combined        SSLEngine on        SSLCertificateFile      /etc/ssl/certs/nzucode.pem        SSLCertificateKeyFile /etc/ssl/private/nzucode.key</VirtualHost># vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Enter fullscreen modeExit fullscreen mode

Kita buat file dengan namanzucode.pem pada directory/etc/ssl/certs/ lalu paste certificate.pem yang di dapat dari cloudflare.

nano /etc/ssl/certs/nzucode.pem
Enter fullscreen modeExit fullscreen mode

Buat juga file dengan namanzucode.key pada directory/etc/ssl/private/ dan pastekan juga certificate.key yang sebelumnya kita dapatkan dari cloudflare juga.

nano /etc/ssl/private/nzucode.key
Enter fullscreen modeExit fullscreen mode

Untuk direktory SSL.pem dan.key bisa di sesuaikan sesuai configsite-available yg kita setting.

Selanjutnya tinggal aktifkanmodul ssl dan enable site confignya (Ini bertujuan untuk enable config nzucode.com.conf)

a2enmod ssl
Enter fullscreen modeExit fullscreen mode
a2ensite nzucode.com.conf
Enter fullscreen modeExit fullscreen mode

Setelah itu pastikan confignya semua benar dengan

apachectl configtest
Enter fullscreen modeExit fullscreen mode

jika terdapat error seperti berikut ini

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this messageSyntax OK
Enter fullscreen modeExit fullscreen mode

Cukup tambahkan syntak berikut iniServerName 127.0.0.1
pada baris paling bawah config file/etc/apache/apache2.conf.

# Include generic snippets of statementsIncludeOptional conf-enabled/*.conf# Include the virtual host configurations:IncludeOptional sites-enabled/*.conf# vim: syntax=apache ts=4 sw=4 sts=4 sr noetServerName 127.0.0.1
Enter fullscreen modeExit fullscreen mode

lalu coba lagi jalankan perintahnya

apachectl configtest
Enter fullscreen modeExit fullscreen mode

jika sudah berhasil lakukanreload danrestart apachenya

systemctl reload apache2.servicesystemctl restart apache2.service
Enter fullscreen modeExit fullscreen mode
  • Step 4: Konfigurasi SSL CertificateTerakhir kita hanya perlu testing denganssl checker

Image description

Coba akses halaman web nya, seharusnya sudahhttps.
Selamat mencoba, semoga bermanfaat.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I'm a DevOps Engineer, my passion is open source technology, Linux administration and programming. I currently work as an IT staff member at a hospital.
  • Education
    Cirebon Muhammadiyah University
  • Work
    Mitra Plumbon Helathcare Group
  • Joined

More fromFega Suseno

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp