पृथà¥?वी पर सà¥?थित à¤à¤¯à¤¾à¤¨à¤• नरक मंदिर | 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 SSL ฟรีบน CentOS 8 ที่ใช้ Apache เป็นเว็บเซิร์ฟเวอร์ เราจะใช้เครื่องมือ certbot เพื่อรับและต่ออายุใบรับรอง
ข้อกำหนดเบื้องต้น
ตรวจสอบให้แน่ใจว่าเป็นไปตามข้อกำหนดเบื้องต้นต่อไปนี้ก่อนดำเนินการต่อ:
- มีชื่อโดเมนที่ชี้ไปที่ IP เซิร์ฟเวอร์สาธารณะของคุณ เราจะใช้
example.com
Apache ติดตั้งและทำงานบนเซิร์ฟเวอร์ของคุณโดยมีโฮสต์เสมือนที่กำหนดค่าไว้สำหรับโดเมนของคุณพอร์ต 80 และ 443 เปิดในไฟร์วอลล์ของคุณ
ติดตั้งแพ็คเกจต่อไปนี้ซึ่งจำเป็นสำหรับเว็บเซิร์ฟเวอร์ที่เข้ารหัส SSL:
sudo dnf install mod_ssl openssl
เมื่อมีการติดตั้งแพ็คเกจ mod_ssl มันควรสร้างคีย์การเซ็นชื่อด้วยตนเองและไฟล์ใบรับรองสำหรับ localhost หากไฟล์ไม่ได้ถูกสร้างขึ้นโดยอัตโนมัติคุณสามารถสร้างได้โดยใช้คำสั่ง
openssl
:
sudo openssl req -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes \
-out /etc/pki/tls/certs/localhost.crt \
-keyout /etc/pki/tls/private/localhost.key
ติดตั้ง Certbot
Certbot เป็นเครื่องมือบรรทัดคำสั่งฟรีที่ช่วยให้กระบวนการรับและต่ออายุ Let's Encrypt ใบรับรอง SSL จากและเปิดใช้งาน HTTPS อัตโนมัติบนเซิร์ฟเวอร์ของคุณ
แพคเกจ certbot ไม่รวมอยู่ในที่เก็บ CentOS 8 มาตรฐาน แต่สามารถดาวน์โหลดได้จากเว็บไซต์ของผู้จำหน่าย
รันคำสั่ง
wget
ต่อไปนี้ในฐานะผู้ใช้รูทหรือ sudo เพื่อดาวน์โหลดสคริปต์ certbot ไปยังไดเร็กทอรี
/usr/local/bin
:
sudo wget -P /usr/local/bin
เมื่อการดาวน์โหลดเสร็จสิ้นให้ทำการเรียกใช้ไฟล์:
sudo chmod +x /usr/local/bin/certbot-auto
สร้างกลุ่ม 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
ไดเรกทอรีที่
${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 apache /var/lib/letsencrypt
sudo chmod g+s /var/lib/letsencrypt
หากต้องการหลีกเลี่ยงการทำซ้ำรหัสและทำให้การกำหนดค่าสามารถบำรุงรักษาได้มากขึ้นให้สร้างตัวอย่างข้อมูลการกำหนดค่าสองแบบต่อไปนี้:
/etc/httpd/conf.d/letsencrypt.conf
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 # Requires Apache 2.4.36 & OpenSSL 1.1.1 SSLProtocol -all +TLSv1.3 +TLSv1.2 SSLOpenSSLConfCmd Curves X25519:secp521r1:secp384r1:prime256v1 # Older versions # 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, HTTP Strict Transport Security (HSTS), คีย์ Dh และบังคับใช้ส่วนหัว HTTP ที่เน้นความปลอดภัยน้อย
โหลดการกำหนดค่า Apache ใหม่เพื่อให้การเปลี่ยนแปลงมีผล:
sudo systemctl reload
ตอนนี้คุณสามารถเรียกใช้สคริปต์ certbot ด้วยปลั๊กอิน webroot และดึงไฟล์ใบรับรอง SSL:
sudo /usr/local/bin/certbot-auto certonly --agree-tos --email [email protected] --webroot -w /var/lib/letsencrypt/ -d example.com -d www.example.com
ในความสำเร็จ certbot จะพิมพ์ข้อความต่อไปนี้:
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/example.com/privkey.pem Your cert will expire on 2020-01-26. To obtain a new or tweaked version of this certificate in the future, simply run certbot-auto again. To non-interactively renew *all* of your certificates, run "certbot-auto renew" - 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:
หลังจากที่ทุกอย่างถูกตั้งค่าแล้วให้แก้ไขการกำหนดค่าโฮสต์เสมือนโดเมนของคุณดังนี้:
/etc/httpd/conf.d/example.com.conf
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 /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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 /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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 /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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 /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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 นอกจากนี้ยังเปิดใช้งาน HTTP / 2 ซึ่งจะทำให้ไซต์ของคุณเร็วขึ้นและมีประสิทธิภาพยิ่งขึ้น ลดลงเพื่อปรับการกำหนดค่าตามความต้องการของคุณ
เริ่มบริการ Apache ใหม่:
sudo systemctl restart
ตอนนี้คุณสามารถเปิดเว็บไซต์ของคุณโดยใช้
https://
และคุณจะสังเกตเห็นไอคอนล็อคสีเขียว
ต่ออายุการเข้ารหัสโดยอัตโนมัติขอใบรับรอง SSL
ใบรับรองของ Encrypt นั้นมีอายุ 90 วัน หากต้องการต่ออายุใบรับรองโดยอัตโนมัติก่อนที่จะหมดอายุเราจะสร้าง cronjob ที่จะทำงานสองครั้งต่อวันและต่ออายุใบรับรองใด ๆ โดยอัตโนมัติ 30 วันก่อนที่จะหมดอายุ
เรียกใช้คำสั่งต่อไปนี้เพื่อสร้าง cronjob ใหม่ซึ่งจะต่ออายุใบรับรองและเริ่ม Apache ใหม่:
echo "0 0, 12 * * * root python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/certbot-auto -q renew --renew-hook \"systemctl reload httpd\"" | sudo tee -a /etc/crontab > /dev/null
เพื่อทดสอบกระบวนการต่ออายุให้ใช้คำสั่ง certbot ตามด้วย
--dry-run
:
sudo /usr/local/bin/certbot-auto renew --dry-run
หากไม่มีข้อผิดพลาดแสดงว่ากระบวนการต่ออายุสำเร็จ
ข้อสรุป
ในบทช่วยสอนนี้เราได้พูดคุยเกี่ยวกับวิธีการใช้ Let's Encrypt client certbot บน CentOS เพื่อรับใบรับรอง SSL สำหรับโดเมนของคุณ คุณได้แสดงวิธีกำหนดค่า Apache ให้ใช้ใบรับรองและตั้งค่า cronjob สำหรับการต่ออายุใบรับรองอัตโนมัติ
หากต้องการเรียนรู้เพิ่มเติมเกี่ยวกับสคริปต์ Certbot โปรดไปที่เอกสารของ Certbot
apache centos ลองเข้ารหัส certbot sslการรักษาความปลอดภัย Apache ด้วย Let's เข้ารหัสบน CentOS 7

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

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

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