എസ്എസ്എൽ ഉപയോഗിച്ച് അപ്പാച്ചെ എങ്ങനെ സുരക്ഷിതമാക്കാം, നമുക്ക് ഫ്രീബിഎസ്ഡിയിൽ എൻക്രിപ്റ്റ് ചെയ്യാം


ഈ ട്യൂട്ടോറിയലിൽ നമുക്ക് FreeBSD 11.x-ൽ നമുക്ക് എൻക്രിപ്റ്റ് ചെയ്യാം TLS/SSL സർട്ടിഫിക്കറ്റുകൾ ഉപയോഗിച്ച് Apache HTTP സെർവർ എങ്ങനെ സുരക്ഷിതമാക്കാമെന്ന് പഠിക്കാം. ലെറ്റ്സിന്റെ എൻക്രിപ്റ്റിനായി സർട്ടിഫിക്കറ്റ് പുതുക്കൽ പ്രക്രിയ എങ്ങനെ ഓട്ടോമേറ്റ് ചെയ്യാമെന്നും ഞങ്ങൾ കവർ ചെയ്യും.

എൻഡ് നോഡുകൾ തമ്മിലുള്ള ആശയവിനിമയം എൻക്രിപ്റ്റ് ചെയ്യുന്നതിന് TLS/SSL സർട്ടിഫിക്കറ്റുകൾ അപ്പാച്ചെ വെബ് സെർവർ ഉപയോഗിക്കുന്നു, അല്ലെങ്കിൽ സുരക്ഷ നൽകുന്നതിനായി സെർവറും ക്ലയന്റും തമ്മിലുള്ള കൂടുതൽ സാധാരണമാണ്. Let's Encrypt certbot കമാൻഡ് ലൈൻ യൂട്ടിലിറ്റി നൽകുന്നു, ഇത് നിങ്ങൾക്ക് വിശ്വസനീയമായ സർട്ടിഫിക്കറ്റുകൾ സൗജന്യമായി ലഭിക്കുന്ന രീതി സുഗമമാക്കാൻ കഴിയുന്ന ഒരു ആപ്ലിക്കേഷനാണ്.

  1. FreeBSD 11.x-ന്റെ ഇൻസ്റ്റാളേഷൻ
  2. FreeBSD ഇൻസ്റ്റാളേഷന് ശേഷം ചെയ്യേണ്ട 10 കാര്യങ്ങൾ
  3. FreeBSD-യിൽ Apache, MariaDB, PHP എന്നിവ എങ്ങനെ ഇൻസ്റ്റാൾ ചെയ്യാം

ഘട്ടം 1: FreeBSD-യിൽ Apache SSL കോൺഫിഗർ ചെയ്യുക

1. certbot യൂട്ടിലിറ്റി ഇൻസ്റ്റാൾ ചെയ്ത് അപ്പാച്ചെയ്uക്കായി TSL കോൺഫിഗറേഷൻ ഫയൽ സൃഷ്uടിക്കാൻ തുടങ്ങുന്നതിനുമുമ്പ്, താഴെ പറയുന്ന കമാൻഡുകൾ നൽകി അപ്പാച്ചെ റൂട്ട് കോൺഫിഗറേഷൻ ഡയറക്uടറിയിൽ സൈറ്റുകൾ-ലഭ്യവും സൈറ്റുകൾ-പ്രാപ്uതമാക്കിയതുമായ രണ്ട് വ്യത്യസ്ത ഡയറക്uടറികൾ സൃഷ്uടിക്കുക.

ഓരോ തവണയും ഒരു പുതിയ വെർച്വൽ ഹോസ്റ്റ് ചേർക്കുമ്പോൾ പ്രധാന Apache httpd.conf കോൺഫിഗറേഷൻ ഫയൽ പരിഷ്കരിക്കാതെ, സിസ്റ്റത്തിലെ വെർച്വൽ ഹോസ്റ്റിംഗ് കോൺഫിഗറേഷൻ മാനേജ്മെന്റ് സുഗമമാക്കുക എന്നതാണ് ഈ രണ്ട് ഡയറക്ടറികളുടെയും ഉദ്ദേശം.

# mkdir /usr/local/etc/apache24/sites-available
# mkdir /usr/local/etc/apache24/sites-enabled

2. നിങ്ങൾ രണ്ട് ഡയറക്uടറികളും സൃഷ്uടിച്ചതിന് ശേഷം, ഒരു ടെക്uസ്uറ്റ് എഡിറ്റർ ഉപയോഗിച്ച് Apache httpd.conf ഫയൽ തുറന്ന് ചുവടെ ചിത്രീകരിച്ചിരിക്കുന്നതുപോലെ ഫയലിന്റെ അവസാനത്തോട് അടുത്ത് ഇനിപ്പറയുന്ന വരി ചേർക്കുക.

# nano /usr/local/etc/apache24/httpd.conf

ഇനിപ്പറയുന്ന വരി ചേർക്കുക:

IncludeOptional etc/apache24/sites-enabled/*.conf

3. അടുത്തതായി, ഇനിപ്പറയുന്ന ഉള്ളടക്കമുള്ള modules.d ഡയറക്uടറിയിൽ 020_mod_ssl.conf എന്ന പേരിൽ ഒരു പുതിയ ഫയൽ സൃഷ്uടിച്ച് അപ്പാച്ചെയ്uക്കായി TLS മൊഡ്യൂൾ പ്രവർത്തനക്ഷമമാക്കുക.

# nano /usr/local/etc/apache24/modules.d/020_mod_ssl.conf

020_mod_ssl.conf ഫയലിലേക്ക് ഇനിപ്പറയുന്ന വരികൾ ചേർക്കുക.

Listen 443
SSLProtocol ALL -SSLv2 -SSLv3
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLPassPhraseDialog  builtin
SSLSessionCacheTimeout  300

4. ഇപ്പോൾ, താഴെ ചിത്രീകരിച്ചിരിക്കുന്നതുപോലെ ഇനിപ്പറയുന്ന വരിയുടെ തുടക്കത്തിൽ നിന്ന് ഹാഷ്uടാഗ് നീക്കം ചെയ്തുകൊണ്ട് /usr/local/etc/apache24/httpd.conf ഫയലിൽ നിന്ന് SSL മൊഡ്യൂൾ അൺകമന്റ് ചെയ്യുക:

LoadModule ssl_module libexec/apache24/mod_ssl.so

5. അടുത്തതായി, സൈറ്റുകളിൽ ലഭ്യമായ ഡയറക്uടറിയിൽ നിങ്ങളുടെ ഡൊമെയ്uനിനായി TLS കോൺഫിഗറേഷൻ ഫയൽ സൃഷ്uടിക്കുക, താഴെയുള്ള ഉദ്ധരണിയിൽ അവതരിപ്പിച്ചിരിക്കുന്നതുപോലെ നിങ്ങളുടെ ഡൊമെയ്uനിന്റെ പേരിനൊപ്പം:

# nano /usr/local/etc/apache24/sites-available/bsd.lan-ssl.conf

bsd.lan-ssl.conf ഫയലിലേക്ക് ഇനിപ്പറയുന്ന virtualhost കോൺഫിഗറേഷൻ ചേർക്കുക.

<VirtualHost *:443>
    ServerName www.yourdomain.com
	ServerAlias yourdomain.com
                DocumentRoot "/usr/local/www/apache24/data/"
	SSLEngine on

	SSLCertificateFile "/usr/local/etc/letsencrypt/live/www.yourdomain.com/cert.pem"
	SSLCertificateKeyFile "/usr/local/etc/letsencrypt/live/www.yourdomain.com/privkey.pem"
	SSLCertificateChainFile "/usr/local/etc/letsencrypt/live/www.yourdomain.com/fullchain.pem"

<FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>

<Directory "/usr/local/www/apache24/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

	BrowserMatch "MSIE [2-5]" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0

	CustomLog "/var/log/apache/httpd-ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

	<Directory "/usr/local/www/apache24/data/">
            Options Indexes FollowSymLinks MultiViews
        #AllowOverride controls what directives may be placed in .htaccess files.       
                        AllowOverride All
        #Controls who can get stuff from this server file
                        Require all granted
        </Directory>
       
    ErrorLog "/var/log/apache/yourdomain.ssl-error.log"
    CustomLog "/var/log/apache/yourdomain.ssl-access_log" combined

</VirtualHost>

ServerName, ServerAlias, ErrorLog, CustomLog പ്രസ്താവനകൾ എന്നിവയിൽ നിന്ന് നിങ്ങൾ ഡൊമെയ്ൻ നെയിം വേരിയബിൾ മാറ്റിസ്ഥാപിക്കുന്നുവെന്ന് ഉറപ്പാക്കുക.

ഘട്ടം 2: FreeBSD-യിൽ Lets'Encrypt ഇൻസ്റ്റാൾ ചെയ്യുക

6. അടുത്ത ഘട്ടത്തിൽ, ലെറ്റ്സ് എൻക്രിപ്റ്റ് നൽകുന്ന certbot യൂട്ടിലിറ്റി ഇൻസ്റ്റാൾ ചെയ്യുന്നതിന് ഇനിപ്പറയുന്ന കമാൻഡ് നൽകുക, ഇത് നിങ്ങളുടെ ഡൊമെയ്uനിനായി Apache TSL സൗജന്യ സർട്ടിഫിക്കറ്റുകൾ നേടുന്നതിന് ഉപയോഗിക്കും.

certbot ഇൻസ്റ്റാൾ ചെയ്യുമ്പോൾ നിങ്ങളുടെ സ്ക്രീനിൽ പ്രോംപ്റ്റിന്റെ ഒരു പരമ്പര ദൃശ്യമാകും. certbot യൂട്ടിലിറ്റി കോൺഫിഗർ ചെയ്യാൻ താഴെയുള്ള സ്ക്രീൻഷോട്ട് ഉപയോഗിക്കുക. കൂടാതെ, നിങ്ങളുടെ മെഷീൻ ഉറവിടങ്ങളെ ആശ്രയിച്ച്, certbot യൂട്ടിലിറ്റി കംപൈൽ ചെയ്യുന്നതിനും ഇൻസ്റ്റാൾ ചെയ്യുന്നതിനും കുറച്ച് സമയമെടുത്തേക്കാം.

# cd /usr/ports/security/py-certbot
# make install clean

7. കംപൈലേഷൻ പ്രക്രിയ പൂർത്തിയായ ശേഷം, certbot യൂട്ടിലിറ്റിയും certbot ആവശ്യമായ ഡിപൻഡൻസികളും അപ്ഡേറ്റ് ചെയ്യുന്നതിന് താഴെയുള്ള കമാൻഡ് നൽകുക.

# pkg install py27-certbot
# pkg install py27-acme

8. നിങ്ങളുടെ ഡൊമെയ്uനിനായി ഒരു സർട്ടിഫിക്കറ്റ് സൃഷ്uടിക്കുന്നതിന്, താഴെ ചിത്രീകരിച്ചിരിക്കുന്നതുപോലെ കമാൻഡ് നൽകുക. -w ഫ്ലാഗ് ഉപയോഗിച്ച് ഫയൽ സിസ്റ്റത്തിൽ (നിങ്ങളുടെ ഡൊമെയ്ൻ കോൺഫിഗറേഷൻ ഫയലിൽ നിന്നുള്ള DocumentRoot നിർദ്ദേശം) നിങ്ങളുടെ വെബ്uസൈറ്റ് ഫയലുകൾ സംഭരിച്ചിരിക്കുന്ന ശരിയായ വെബ്uറൂട്ട് ലൊക്കേഷൻ നിങ്ങൾ നൽകിയിട്ടുണ്ടെന്ന് ഉറപ്പാക്കുക. നിങ്ങൾക്ക് ഒന്നിലധികം ഉപഡൊമെയ്uനുകൾ ഉണ്ടെങ്കിൽ അവയെല്ലാം -d ഫ്ലാഗ് ഉപയോഗിച്ച് ചേർക്കുക.

# certbot certonly --webroot -w /usr/local/www/apache24/data/ -d yourdomain.com -d www.yourdomain.com

സർട്ടിഫിക്കറ്റ് ലഭിക്കുമ്പോൾ, സർട്ടിഫിക്കറ്റ് പുതുക്കുന്നതിന് ഒരു ഇമെയിൽ വിലാസം നൽകുക, ലെറ്റ്സ് എൻക്രിപ്റ്റ് നിബന്ധനകളും വ്യവസ്ഥകളും അംഗീകരിക്കാൻ ഒരു അമർത്തുക, ഇമെയിൽ വിലാസം പങ്കിടാതിരിക്കാൻ n പങ്കാളികളെ എൻക്രിപ്റ്റ് ചെയ്യാം.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):[email 
There seem to be problems with that address. Enter email address (used for
urgent renewal and security notices)  If you really want to skip this, you can
run the client with --register-unsafely-without-email but make sure you then
backup your account key from /etc/letsencrypt/accounts   (Enter 'c' to cancel):[email 

-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: a ------------------------------------------------------------------------------- Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about EFF and our work to encrypt the web, protect its users and defend digital rights. ------------------------------------------------------------------------------- (Y)es/(N)o: n Obtaining a new certificate Performing the following challenges: http-01 challenge for www.domain.com Using the webroot path /usr/local/www/apache24/data for all unmatched domains. Waiting for verification... Cleaning up challenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /usr/local/etc/letsencrypt/live/www.yourdomain.com/fullchain.pem. Your cert will expire on 2017-11-15. 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" - Your account credentials have been saved in your Certbot configuration directory at /usr/local/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: https://eff.org/donate-le

9. നിങ്ങളുടെ ഡൊമെയ്uനിനായുള്ള സർട്ടിഫിക്കറ്റുകൾ നിങ്ങൾ നേടിയ ശേഷം, ചുവടെയുള്ള ഉദാഹരണത്തിൽ അവതരിപ്പിച്ചിരിക്കുന്നതുപോലെ എല്ലാ സർട്ടിഫിക്കറ്റിന്റെ ഘടകങ്ങളും (ചെയിൻ, പ്രൈവറ്റ് കീ, സർട്ടിഫിക്കറ്റ്) ലിസ്റ്റുചെയ്യുന്നതിന് നിങ്ങൾക്ക് ls കമാൻഡ് പ്രവർത്തിപ്പിക്കാൻ കഴിയും.

# ls -al /usr/local/etc/letsencrypt/live/www.yourdomain.com/

ഘട്ടം 3: FreeBSD-യിൽ Apache TLS സർട്ടിഫിക്കറ്റുകൾ അപ്ഡേറ്റ് ചെയ്യുക

10. നിങ്ങളുടെ വെബ്uസൈറ്റിലേക്ക് നമുക്ക് എൻക്രിപ്റ്റ് സർട്ടിഫിക്കറ്റുകൾ ചേർക്കുന്നതിന്, നിങ്ങളുടെ ഡൊമെയ്uനിനായി അപ്പാച്ചെ കോൺഫിഗറേഷൻ ഫയൽ തുറന്ന് ഇഷ്യൂ ചെയ്ത സർട്ടിഫിക്കറ്റുകളുടെ പാത പ്രതിഫലിപ്പിക്കുന്നതിന് ഇനിപ്പറയുന്ന വരികൾ അപ്uഡേറ്റ് ചെയ്യുക.

# nano /usr/local/etc/apache24/sites-available/bsd.lan-ssl.conf

ഈ TLS സർട്ടിഫിക്കറ്റ് ലൈനുകൾ ചേർക്കുക:

SSLCertificateFile "/usr/local/etc/letsencrypt/live/www.yourdomain.com/cert.pem"
	SSLCertificateKeyFile "/usr/local/etc/letsencrypt/live/www.yourdomain.com/privkey.pem"
	SSLCertificateChainFile "/usr/local/etc/letsencrypt/live/www.yourdomain.com/fullchain.pem"

11. അവസാനമായി, TLS കോൺഫിഗറേഷൻ ഫയൽ പ്രവർത്തനക്ഷമമാക്കുക, നിങ്ങളുടെ ഡൊമെയ്uൻ TLS കോൺഫിഗറേഷൻ ഫയലിനായി സൈറ്റുകൾ-പ്രാപ്uതമാക്കിയ ഡയറക്uടറിയിലേക്ക് ഒരു സിംലിങ്ക് സൃഷ്uടിക്കുക, സാധ്യമായ വാക്യഘടന പിശകുകൾക്കായി അപ്പാച്ചെ കോൺഫിഗറേഷനുകൾ പരിശോധിക്കുക, വാക്യഘടന ശരിയാണെങ്കിൽ, ചുവടെയുള്ള കമാൻഡുകൾ നൽകി അപ്പാച്ചെ ഡെമൺ പുനരാരംഭിക്കുക.

# ln -sf /usr/local/etc/apache24/sites-available/bsd.lan-ssl.conf /usr/local/etc/apache24/sites-enabled/
# apachectl -t
# service apache24 restart

12. HTTPS പോർട്ട് 443-ൽ അപ്പാച്ചെ സേവനം കേൾക്കുന്നുണ്ടോയെന്ന് പരിശോധിക്കുന്നതിന്, httpd നെറ്റ്uവർക്ക് സോക്കറ്റുകൾ ലിസ്റ്റുചെയ്യുന്നതിന് ഇനിപ്പറയുന്ന കമാൻഡ് നൽകുക.

# sockstat -4 | grep httpd

13. എൻക്രിപ്റ്റ് ചെയ്യട്ടെ സർട്ടിഫിക്കറ്റുകൾ വിജയകരമായി പ്രയോഗിച്ചുവെന്ന് സ്ഥിരീകരിക്കുന്നതിന് HTTPS പ്രോട്ടോക്കോൾ വഴി ബ്രൗസറിൽ നിന്ന് നിങ്ങളുടെ ഡൊമെയ്ൻ വിലാസത്തിലേക്ക് നാവിഗേറ്റ് ചെയ്യാം.

https://www.yourdomain.com

14. കമാൻഡ് ലൈനിൽ നിന്ന് ഇഷ്യൂ ചെയ്ത ലെറ്റ്സ് എൻക്രിപ്റ്റ് സർട്ടിഫിക്കറ്റിനെ കുറിച്ചുള്ള അധിക വിവരങ്ങൾ ലഭിക്കുന്നതിന്, ഇനിപ്പറയുന്ന രീതിയിൽ openssl കമാൻഡ് ഉപയോഗിക്കുക.

# openssl s_client -connect www.yourdomain.com:443

15. ചുവടെയുള്ള മൊബൈൽ സ്ക്രീൻഷോട്ടിൽ ചിത്രീകരിച്ചിരിക്കുന്നതുപോലെ ഒരു മൊബൈൽ ഉപകരണത്തിൽ നിന്ന് CA എൻക്രിപ്റ്റ് ചെയ്യാം എന്ന സാധുവായ സർട്ടിഫിക്കറ്റ് ഉപയോഗിച്ച് ട്രാഫിക് എൻക്രിപ്റ്റ് ചെയ്തിട്ടുണ്ടോയെന്ന് നിങ്ങൾക്ക് പരിശോധിക്കാനും കഴിയും.

അത്രയേയുള്ളൂ! സെർവറിനും ക്ലയന്റിന്റെ ബ്രൗസറിനും ഇടയിൽ ഒഴുകുന്ന ട്രാഫിക് എൻക്രിപ്റ്റ് ചെയ്തിരിക്കുന്നതിനാൽ ക്ലയന്റുകൾക്ക് ഇപ്പോൾ നിങ്ങളുടെ വെബ്uസൈറ്റ് സുരക്ഷിതമായി സന്ദർശിക്കാനാകും. certbot യൂട്ടിലിറ്റിയുമായി ബന്ധപ്പെട്ട കൂടുതൽ സങ്കീർണ്ണമായ ജോലികൾക്കായി ഇനിപ്പറയുന്ന ലിങ്ക് സന്ദർശിക്കുക: https://certbot.eff.org/