RHEL7: How to migrate your website to HTTPS with Letsencrypt.

Share this link

Presentation

It is now pretty easy to put in place a webserver using the https protocol through the Letsencrypt project.

Prerequisites

A webserver has to be running (Apache, Nginx, etc)  on the port 80 with the firewall configuration allowing access through.

Installation Procedure

In the following tutorial, let’s assume that your website is called www.example.com and is located in the /var/www/html/example directory.

Several packages need to be installed:

# yum install -y git
# cd /opt
# git clone https://github.com/letsencrypt/letsencrypt
# cd letsencrypt

Then, create a certificate for a website (here www.example.com):

# ./letsencrypt-auto certonly --webroot -w /var/www/html/example -d example.com \
-d www.example.com --email myemail@mail.com
...
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
  /etc/letsencrypt/live/example.com/fullchain.pem. Your cert will
  expire on 2016-08-18. To obtain a new version of the certificate in
  the future, simply run Certbot again.
- If you lose your account credentials, you can recover through
  e-mails sent to myemail@mail.com.
- 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: https://eff.org/donate-le

Note: If you host several websites on the same domain don’t specify the domain (here example.com).

Change the firewall configuration to allow https:

# firewall-cmd --permanent --add-service=https
# firewall-cmd --reload

Apache Configuration

Install the mod_ssl package if it is not already there:

# yum install -y mod_ssl

Edit the /etc/httpd/conf.d/ssl.conf file, search for the SSLCertificate string and replace as follows:

SSLCertificateFile /etc/letsencrypt/live/www.example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
SSLCACertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem

In the same file, search for the ServerName string and replace as follows:

ServerName www.example.com:443

Again, search for the SSLProtocol string and replace as follows:

SSLProtocol all -SSLv2 -SSLv3

Search for the SSLCipherSuite string and replace as follows:

SSLHonorCipherOrder on
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM \
 EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 \
 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 \
 EECDH !ECDHE-RSA-DES-CBC3-SHA EDH+aRSA RSA+3DES \
 !aNULL !eNULL !LOW !SEED !CAMELLIA !MD5 !EXP !PSK !SRP !DSS !RC4"

Check the validity of the configuration:

# httpd -t
Syntax OK

Restart the Apache webserver:

# apachectl restart

If an error occurs, check the /var/log/httpd/error_log and /var/log/httpd/ssl_error_log files.

Check the virtual host configuration:

# httpd -D DUMP_VHOSTS
VirtualHost configuration:
*:443                  www.example.com (/etc/httpd/conf.d/ssl.conf:56)

Nginx Configuration

Change the listen directive in your server block:

listen 443 http2 ssl;

Note: http2 is optional.

Add the certificate directives to your server block:

ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;

Specify the protocols and cyphers used:

ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:\
DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:HIGH:!aNULL:!MD5:!kEDH;

Add a server block to redirect access to port 80 to port 443:

server {
    listen       80;
    server_name  www.example.com;
    return       301 https://www.example.com$request_uri;
}

Test the syntax correctness:

# nginx -t

Restart the Nginx server:

# systemctl restart nginx

If an error occurs, check the /var/log/nginx directory.

Time To Test

To test your new certificate, go to the ssllabs website and type the url of your website.
Similarly, the use of the HTTP/2 protocol can be tested through the Keycdn website.

If your website uses WordPress, there will be some additional WordPress configuration steps to migrate to HTTPS.

Certificate Renewal

Certificates are only valid for 90 days. That means you need to renew them regularly.
Automate this process is a good idea.

Create a file called /etc/letsencrypt/cli.ini and paste the following lines:

authenticator = webroot
webroot-path = /opt/www/html/example
server = https://acme-v01.api.letsencrypt.org/directory
renew-by-default
agree-tos
email = mymail@mail.com

Create a script called /etc/letsencrypt/renew.sh and paste the following lines:

#!/bin/bash
/root/.local/share/letsencrypt/bin/letsencrypt certonly \
-c /etc/letsencrypt/cli.ini -d www.example.com

Uncomment this line if you use Apache
#/bin/systemctl reload httpd

Uncomment this line if you use Nginx
#/bin/systemctl reload nginx

Give execution rights:

# chmod u+x /etc/letsencrypt/renew.sh

Put the script in the root crontab (1 execution per week):

47 5 * * 1 /etc/letsencrypt/renew.sh > /dev/null 2<&1

Additional Resources

The idroot.net website provides a tutorial showing How To Install Let’s Encrypt SSL With Nginx on CentOS 7.

(No Ratings Yet)
Loading...

Upcoming Events (Local Time)

There are no events.

Follow me on Twitter

Archives

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |