Introduction to Amazon Web Services by Leo Zhadanovsky
جدول المحتويات:
- المتطلبات الأساسية
- تثبيت Certbot
- إنشاء مجموعة قوية Dh (ديفي هيلمان)
- الحصول على شهادة دعونا تشفير SSL
- التجديد التلقائي دعونا تشفير شهادة SSL
- استنتاج
Let's Encrypt هي مرجع شهادات مجاني وأتمتة ومفتوح تم تطويره بواسطة مجموعة أبحاث أمان الإنترنت (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 ، يجب أن تنشئ مفتاحًا موقَّعًا ذاتيًا وملفات شهادة للمضيف المحلي. إذا لم يتم إنشاء الملفات تلقائيًا ، يمكنك إنشائها باستخدام أمر
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 هي أداة سطر أوامر مجانية تعمل على تبسيط عملية الحصول على وتجديد شهادات دعونا تشفير 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
إنشاء مجموعة قوية Dh (ديفي هيلمان)
يعد Diffie – Hellman key exchange (DH) طريقة لتبادل آمن لمفاتيح التشفير عبر قناة اتصال غير آمنة. إنشاء مجموعة جديدة من معلمات DH 2048 بت لتعزيز الأمن:
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
يمكنك تغيير الحجم إلى 4096 بت ، لكن قد يستغرق الجيل أكثر من 30 دقيقة اعتمادًا على إنتروبيا النظام.
الحصول على شهادة دعونا تشفير 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 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"
يستخدم القصاصة أعلاه الأغصان الموصى بها بواسطة 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
شهادات تشفير دعونا صالحة لمدة 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
إذا لم تكن هناك أخطاء ، فهذا يعني أن عملية التجديد كانت ناجحة.
استنتاج
في هذا البرنامج التعليمي ، تحدثنا عن كيفية استخدام certbot العميل Let's Encrypt على CentOS للحصول على شهادات SSL لنطاقاتك. لقد أوضحت لك أيضًا كيفية تكوين Apache لاستخدام الشهادات وإعداد cronjob لتجديد الشهادة تلقائيًا.
لمعرفة المزيد حول البرنامج النصي Certbot ، تفضل بزيارة وثائق Certbot.
اباتشي centos دعونا تشفير certbot SSLتأمين اباتشي مع دعونا تشفير على centos 7
في هذا البرنامج التعليمي ، سنغطي الخطوات اللازمة لتثبيت شهادة Let's Encrypt SSL المجانية على خادم CentOS 7 يشغل Apache كخادم ويب.
تأمين اباتشي مع دعونا تشفير على ديبيان 9
سيرشدك هذا البرنامج التعليمي خلال عملية الحصول على Let's Encrypt المجاني باستخدام أداة certbot في Debian 9. وسنعرض أيضًا كيفية تكوين Apache لاستخدام شهادة SSL الجديدة وتمكين HTTP / 2
تأمين اباتشي مع دعونا تشفير على أوبونتو 18.04
في هذا البرنامج التعليمي ، سنقدم إرشادات خطوة بخطوة حول كيفية تأمين Apache باستخدام Let's Encrypt باستخدام أداة certbot على Ubuntu 18.04.







