पृथà¥?वी पर सà¥?थित à¤à¤¯à¤¾à¤¨à¤• नरक मंदिर | Amazing H
สารบัญ:
- ข้อกำหนดเบื้องต้น
- ติดตั้ง Certbot
- สร้างกลุ่ม Strong Dh (Diffie-Hellman)
- รับใบรับรอง Let's Encrypt SSL
- ต่ออายุการเข้ารหัสโดยอัตโนมัติขอใบรับรอง SSL
- ข้อสรุป
Let's Encrypt เป็นผู้ออกใบรับรองที่สร้างขึ้นโดย Internet Security Research Group (ISRG) มันมอบใบรับรอง SSL ฟรีผ่านกระบวนการอัตโนมัติที่ออกแบบมาเพื่อกำจัดการสร้างใบรับรองด้วยตนเองการตรวจสอบความถูกต้องการติดตั้งและการต่ออายุ
ใบรับรองที่ออกโดย Let's Encrypt นั้นมีอายุ 90 วันนับจากวันที่ออกและน่าเชื่อถือโดยเบราว์เซอร์หลักทุกวันนี้
บทช่วยสอนนี้จะแนะนำคุณตลอดกระบวนการรับ Let's Encrypt ฟรีโดยใช้เครื่องมือ certbot ใน Debian 9 นอกจากนี้เราจะแสดงวิธีกำหนดค่า Apache ให้ใช้ใบรับรอง SSL ใหม่และเปิดใช้งาน HTTP / 2
ข้อกำหนดเบื้องต้น
ตรวจสอบให้แน่ใจว่าคุณได้ทำตามข้อกำหนดเบื้องต้นต่อไปนี้ก่อนที่จะดำเนินการกับบทช่วยสอนนี้:
- เข้าสู่ระบบในฐานะผู้ใช้ที่มีสิทธิ์ sudo มีชื่อโดเมนที่ชี้ไปยัง IP เซิร์ฟเวอร์สาธารณะของคุณ เราจะใช้
example.com
.Aache ติดตั้ง โฮสต์เสมือน apache สำหรับโดเมนของคุณ คุณสามารถทำตามคำแนะนำเหล่านี้สำหรับรายละเอียดเกี่ยวกับวิธีการสร้าง
ติดตั้ง Certbot
Certbot เป็นเครื่องมือที่มีคุณลักษณะครบถ้วนและใช้งานง่ายซึ่งสามารถทำงานโดยอัตโนมัติเพื่อรับและต่ออายุ Let's Encrypt SSL certificate แพคเกจ certbot รวมอยู่ในที่เก็บ Debian เริ่มต้น
อัพเดตรายการแพ็กเกจและติดตั้งแพ็กเกจ certbot โดยใช้คำสั่งต่อไปนี้:
sudo apt update
sudo apt install certbot
สร้างกลุ่ม Strong Dh (Diffie-Hellman)
การแลกเปลี่ยนคีย์ Diffie – Hellman (DH) เป็นวิธีการแลกเปลี่ยนคีย์เข้ารหัสลับอย่างปลอดภัยผ่านช่องทางการสื่อสารที่ไม่ปลอดภัย
ในการสร้างชุดพารามิเตอร์ DH 2048 บิตใหม่ให้ทำดังนี้
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
หากคุณต้องการคุณสามารถเปลี่ยนขนาดได้สูงสุด 4096 บิต แต่ในกรณีนี้การสร้างอาจใช้เวลานานกว่า 30 นาทีขึ้นอยู่กับเอนโทรปีของระบบ
รับใบรับรอง Let's Encrypt SSL
ในการรับใบรับรอง SSL สำหรับโดเมนของเราเราจะใช้ปลั๊กอิน Webroot ที่ทำงานโดยการสร้างไฟล์ชั่วคราวสำหรับการตรวจสอบโดเมนที่ร้องขอในไดเรกทอรี
${webroot-path}/.well-known/acme-challenge
เซิร์ฟเวอร์ Let's Encrypt ส่งคำขอ HTTP ไปยังไฟล์ชั่วคราวเพื่อตรวจสอบว่าโดเมนที่ร้องขอแก้ไขไปยังเซิร์ฟเวอร์ที่ Certbot ทำงานอยู่
เพื่อให้ง่ายยิ่งขึ้นเราจะทำแผนที่คำขอ HTTP ทั้งหมดสำหรับ
.well-known/acme-challenge
ไปยังไดเรกทอรีเดียว
/var/lib/letsencrypt
คำสั่งต่อไปนี้สร้างไดเรกทอรีและทำให้สามารถเขียนได้สำหรับเซิร์ฟเวอร์ Apache
sudo mkdir -p /var/lib/letsencrypt/.well-known
sudo chgrp www-data /var/lib/letsencrypt
sudo chmod g+s /var/lib/letsencrypt
หากต้องการหลีกเลี่ยงการทำรหัสซ้ำให้สร้างตัวอย่างข้อมูลการกำหนดค่าสองรายการต่อไปนี้:
Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/" AllowOverride None Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS
Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/" AllowOverride None Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 SSLHonorCipherOrder On Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" Header always set X-Frame-Options DENY Header always set X-Content-Type-Options nosniff # Requires Apache >= 2.4 SSLCompression off SSLUseStapling on SSLStaplingCache "shmcb:logs/stapling-cache(150000)" # Requires Apache >= 2.4.11 SSLSessionTickets Off SSLOpenSSLConfCmd DHParameters "/etc/ssl/certs/dhparam.pem"
ตัวอย่างข้างต้นใช้ chippers ที่ Cipherli.st แนะนำให้เปิดใช้งาน OCSP Stapling, HTTP Strict Transport Security (HSTS) และบังคับใช้ส่วนหัว HTTP HTTP ที่เน้นความปลอดภัยเล็กน้อย
ก่อนเปิดใช้งานไฟล์กำหนดค่าตรวจสอบให้แน่ใจว่าทั้ง
mod_ssl
และ
mod_headers
เปิดใช้งานโดยการออก:
sudo a2enmod ssl
sudo a2enmod headers
เปิดใช้งานโมดูล HTTP / 2 ซึ่งจะทำให้ไซต์ของคุณเร็วขึ้นและมีประสิทธิภาพยิ่งขึ้น:
sudo a2enmod
เปิดใช้งานไฟล์คอนฟิกูเรชัน SSL โดยการรันคำสั่งต่อไปนี้:
sudo a2enconf letsencrypt
sudo a2enconf ssl-params
โหลดการกำหนดค่า Apache ใหม่เพื่อให้การเปลี่ยนแปลงมีผล:
sudo systemctl reload apache2
ใช้เครื่องมือ Certbot กับปลั๊กอิน webroot เพื่อรับไฟล์ใบรับรอง SSL:
sudo certbot certonly --agree-tos --email [email protected] --webroot -w /var/lib/letsencrypt/ -d example.com -d www.example.com
หากได้รับใบรับรอง SSL เรียบร้อยแล้ว certbot จะพิมพ์ข้อความต่อไปนี้:
IMPORTANT NOTES: IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/example.com/fullchain.pem. Your cert will expire on 2019-01-17. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you lose your account credentials, you can recover through e-mails sent to [email protected]. - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF:
หลังจากที่คุณมีไฟล์ใบรับรองแล้วให้แก้ไขการกำหนดค่าโฮสต์เสมือนโดเมนของคุณดังนี้:
ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem # Other Apache Configuration
ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem # Other Apache Configuration
ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem # Other Apache Configuration
ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem # Other Apache Configuration
ด้วยการกำหนดค่าข้างต้นเรากำลังบังคับใช้ HTTPS และเปลี่ยนเส้นทางจาก www เป็นรุ่นที่ไม่ใช่ www ลดลงเพื่อปรับการกำหนดค่าตามความต้องการของคุณ
โหลดบริการ Apache อีกครั้งเพื่อให้การเปลี่ยนแปลงมีผล:
sudo systemctl reload apache2
เปิดเว็บไซต์ของคุณโดยใช้
https://
และคุณจะสังเกตเห็นไอคอนล็อคสีเขียว
ต่ออายุการเข้ารหัสโดยอัตโนมัติขอใบรับรอง SSL
ใบรับรองของ Encrypt นั้นมีอายุ 90 วัน หากต้องการต่ออายุใบรับรองโดยอัตโนมัติก่อนที่จะหมดอายุแพ็คเกจ certbot จะสร้าง cronjob ที่รันสองครั้งต่อวันและจะต่ออายุใบรับรองใด ๆ โดยอัตโนมัติ 30 วันก่อนหมดอายุ
เมื่อต่ออายุใบรับรองแล้วเรายังต้องโหลดบริการ Apache อีกครั้ง ผนวก
--renew-hook "systemctl reload apache2"
ไปยังไฟล์
/etc/cron.d/certbot
ดังนั้นจึงดูเหมือนว่าดังต่อไปนี้:
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew --renew-hook "systemctl reload apache2"
หากต้องการทดสอบกระบวนการต่ออายุให้ใช้สวิตช์
--dry-run
:
sudo certbot renew --dry-run
หากไม่มีข้อผิดพลาดแสดงว่ากระบวนการต่ออายุสำเร็จ
ข้อสรุป
ในบทช่วยสอนนี้คุณใช้ Let's Encrypt ไคลเอ็นต์ certbot เพื่อรับใบรับรอง SSL สำหรับโดเมนของคุณ คุณได้สร้างชุดย่อย Apache เพื่อหลีกเลี่ยงการทำซ้ำรหัสและกำหนดค่า Apache ให้ใช้ใบรับรอง ในตอนท้ายของบทช่วยสอนคุณได้ตั้งค่า cronjob สำหรับการต่ออายุใบรับรองอัตโนมัติ
apache debian ลองเข้ารหัส certbot sslโพสต์นี้เป็นส่วนหนึ่งของวิธีการติดตั้ง LAMP Stack บน Debian 9 series
โพสต์อื่น ๆ ในชุดนี้:
•วิธีการติดตั้ง Apache บน Debian 9 •วิธีการติดตั้ง PHP บน Debian 9 •วิธีการตั้งค่า Apache โฮสต์เสมือนบน Debian 9 •วิธีการติดตั้ง MariaDB บน Debian 9 • Secure Apache ด้วย Let's Encrypt บน Debian 9การรักษาความปลอดภัย Apache ด้วย Let's เข้ารหัสบน CentOS 7

ในบทช่วยสอนนี้เราจะกล่าวถึงขั้นตอนที่จำเป็นในการติดตั้งใบรับรอง Let's Encrypt SSL ฟรีบนเซิร์ฟเวอร์ CentOS 7 ที่ใช้ Apache เป็นเว็บเซิร์ฟเวอร์
การรักษาความปลอดภัย Apache ด้วย Let's เข้ารหัสบน CentOS 8

บทช่วยสอนนี้อธิบายวิธีติดตั้งใบรับรอง Let's Encrypt SSL ฟรีบน CentOS 8 ที่ใช้ Apache เป็นเว็บเซิร์ฟเวอร์ เราจะใช้เครื่องมือ certbot เพื่อรับและต่ออายุใบรับรอง
การรักษาความปลอดภัย Apache ด้วย Let's เข้ารหัสบน Ubuntu 18.04

ในบทช่วยสอนนี้เราจะให้คำแนะนำทีละขั้นตอนเกี่ยวกับการรักษาความปลอดภัย Apache ของคุณด้วย Let's Encrypt โดยใช้เครื่องมือ certbot บน Ubuntu 18.04