| 519 | |
| 520 | = Secure the Web Sites with Let's Encrypt = |
| 521 | |
| 522 | To secure web sites we need to install TLS/SSL certificates on the servers. These certificates are normally purchased from certificate vendors. But using Let's Encrypt we can have these certificates freely and easily. Here we will go through the steps to install certificates for your domains. |
| 523 | |
| 524 | Let's Encrypt simplifies the process by providing a software client called Certbot, that attempts to automate most of the required steps. So first we need to install the certbot. |
| 525 | |
| 526 | {{{ |
| 527 | sudo apt install certbot python3-certbot-apache |
| 528 | }}} |
| 529 | |
| 530 | Once install we need to verify that in virtual host configuration we have set the ServerName and ServerAlias directives properly. |
| 531 | |
| 532 | {{{ |
| 533 | sudo nano /etc/apache2/sites-available/wp.your_domain.com.conf |
| 534 | |
| 535 | ServerName wp.your_domain.com |
| 536 | ServerAlias wp.your_domain.com |
| 537 | }}} |
| 538 | |
| 539 | Then we will go ahead with obtaining the certicates using below command. |
| 540 | |
| 541 | {{{ |
| 542 | sudo certbot --apache |
| 543 | }}} |
| 544 | |
| 545 | In the process it will ask for a valid email address which will be used for renewal notifications and security notices. Let's provide it. |
| 546 | |
| 547 | {{{ |
| 548 | Saving debug log to /var/log/letsencrypt/letsencrypt.log |
| 549 | Plugins selected: Authenticator apache, Installer apache |
| 550 | Enter email address (used for urgent renewal and security notices) (Enter 'c' to |
| 551 | cancel): lalantha@learn.ac.lk |
| 552 | }}} |
| 553 | |
| 554 | You will then be prompted to confirm if you agree to Let’s Encrypt terms of service. You can confirm by pressing A and then ENTER. |
| 555 | |
| 556 | {{{ |
| 557 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 558 | Please read the Terms of Service at |
| 559 | https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must |
| 560 | agree in order to register with the ACME server at |
| 561 | https://acme-v02.api.letsencrypt.org/directory |
| 562 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 563 | (A)gree/(C)ancel: A |
| 564 | |
| 565 | }}} |
| 566 | |
| 567 | Next, you’ll be asked if you would like to share your email with the Electronic Frontier Foundation to receive news and other information. |
| 568 | |
| 569 | {{{ |
| 570 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 571 | Would you be willing to share your email address with the Electronic Frontier |
| 572 | Foundation, a founding partner of the Let's Encrypt project and the non-profit |
| 573 | organization that develops Certbot? We'd like to send you email about our work |
| 574 | encrypting the web, EFF news, campaigns, and ways to support digital freedom. |
| 575 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 576 | (Y)es/(N)o: N |
| 577 | }}} |
| 578 | |
| 579 | Then the certbot will give an list of domains that it discoverd and to select one or more domains to obtain the certificates. For this I will choose only 3rd domain. |
| 580 | |
| 581 | {{{ |
| 582 | Which names would you like to activate HTTPS for? |
| 583 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 584 | 1: lms.your_domain.com |
| 585 | 2: web.your_domain.com |
| 586 | 3: wp.your_domain.com |
| 587 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 588 | Select the appropriate numbers separated by commas and/or spaces, or leave input |
| 589 | blank to select all options shown (Enter 'c' to cancel): 3 |
| 590 | }}} |
| 591 | |
| 592 | Next, you’ll be prompted to select whether or not you want HTTP traffic redirected to HTTPS. In practice, that means when someone visits your website through unencrypted channels (HTTP), they will be automatically redirected to the HTTPS address of your website. Choose 2 to enable the redirection. |
| 593 | |
| 594 | {{{ |
| 595 | Obtaining a new certificate |
| 596 | Performing the following challenges: |
| 597 | http-01 challenge for wp.dhammikalalantha.com |
| 598 | Waiting for verification... |
| 599 | Cleaning up challenges |
| 600 | Created an SSL vhost at /etc/apache2/sites-available/wp.dhammikalalantha.com-le-ssl.conf |
| 601 | Enabled Apache socache_shmcb module |
| 602 | Enabled Apache ssl module |
| 603 | Deploying Certificate to VirtualHost /etc/apache2/sites-available/wp.dhammikalalantha.com-le-ssl.conf |
| 604 | Enabling available site: /etc/apache2/sites-available/wp.dhammikalalantha.com-le-ssl.conf |
| 605 | |
| 606 | Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. |
| 607 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 608 | 1: No redirect - Make no further changes to the webserver configuration. |
| 609 | 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for |
| 610 | new sites, or if you're confident your site works on HTTPS. You can undo this |
| 611 | change by editing your web server's configuration. |
| 612 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 613 | Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 |
| 614 | |
| 615 | }}} |
| 616 | |
| 617 | Finally the below will be printed and if successful certificates will be installed. |
| 618 | |
| 619 | {{{ |
| 620 | Redirecting vhost in /etc/apache2/sites-enabled/wp.dhammikalalantha.com.conf to ssl vhost in /etc/apache2/sites-available/wp.dhammikalalantha.com-le-ssl.conf |
| 621 | |
| 622 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 623 | Congratulations! You have successfully enabled https://wp.dhammikalalantha.com |
| 624 | |
| 625 | You should test your configuration at: |
| 626 | https://www.ssllabs.com/ssltest/analyze.html?d=wp.dhammikalalantha.com |
| 627 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 628 | |
| 629 | IMPORTANT NOTES: |
| 630 | - Congratulations! Your certificate and chain have been saved at: |
| 631 | /etc/letsencrypt/live/wp.dhammikalalantha.com/fullchain.pem |
| 632 | Your key file has been saved at: |
| 633 | /etc/letsencrypt/live/wp.dhammikalalantha.com/privkey.pem |
| 634 | Your cert will expire on 2023-02-20. To obtain a new or tweaked |
| 635 | version of this certificate in the future, simply run certbot again |
| 636 | with the "certonly" option. To non-interactively renew *all* of |
| 637 | your certificates, run "certbot renew" |
| 638 | - Your account credentials have been saved in your Certbot |
| 639 | configuration directory at /etc/letsencrypt. You should make a |
| 640 | secure backup of this folder now. This configuration directory will |
| 641 | also contain certificates and private keys obtained by Certbot so |
| 642 | making regular backups of this folder is ideal. |
| 643 | - If you like Certbot, please consider supporting our work by: |
| 644 | |
| 645 | Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate |
| 646 | Donating to EFF: https://eff.org/donate-le |
| 647 | }}} |
| 648 | |
| 649 | Please visit your domain now check whether SSL is enabled. |
| 650 | |
| 651 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web25.png)]] |