Let ' sencrypt certified website HTTPS configuration

Source: Internet
Author: User

It is recommended to use this script to specify that there are

Https://github.com/xdtianyu/scripts/tree/master/le-dns

It is implemented by invoking the DNS provider's API to update the TXT record, without specifying the site directory and DNS resolution, to support Dnspod and Cloudxns after the two service providers have finished reading this article with apachehttps://www.cloudxns.net/ Support/detail/id/906.html ============ I'm a split line =============
    1. Let's get a folder and put things.
      Mkdir/usr/local/openssl
    2. Generate keys for accounts and websites
      OpenSSL genrsa 4096 > Account.key
      OpenSSL genrsa 4096 > Zhiyi.key
    3. Generate certificate
      OpenSSL req-new-sha256-key zhiyi.key-subj "/"-reqexts San-config < (cat/etc/pki/tls/openssl.cnf < (printf "[SAN ]\nsubjectaltname=dns:snsproject.com,dns:www.snsproject.com ")) > ZHIYI.CSR
      If you can not find OPENSSL.CNF, the first global search where this file, if not found on the installation of a OpenSSL
    4. Download a Python gadget
      wget https://raw.githubusercontent.com/diafygi/acme-tiny/master/acme_tiny.py
    5. Run it, generate the signed CRT file for validation
      Python./acme_tiny.py--account-key/account.key--csr/zhiyi.csr--acme-dir./www/acme-challenge/>/signed.crt
      Note that it generates a file and then gets the file for validation through the http://yoursite.com/.well-known/acme-challenge/+ file name, so make sure that the file is accessible through the URL just now

6. After you have signed, generate a Web site certificate

Wget-o-HTTPS://LETSENCRYPT.ORG/CERTS/LETS-ENCRYPT-X1-CROSS-SIGNED.PEM > Intermediate.pem

Cat Signed.crt Intermediate.pem > Chained.pem

7. The deployment of the article please see the previous written

8. Because the certificate is valid for 90 days, the certificate script needs to be refreshed automatically

VI autorefresh.sh

#!/bin/bash

cd/usr/local/openssl/
Python./acme_tiny.py--account-key/account.key--csr/zhiyi.csr--acme-dir./www/acme-challenge/>/signed.crt
Wget-o-HTTPS://LETSENCRYPT.ORG/CERTS/LETS-ENCRYPT-X1-CROSS-SIGNED.PEM > Intermediate.pem
Cat Signed.crt Intermediate.pem > Chained.pem
Service httpd Restart

Vi/etc/crontab

Add a line at the end

0 0 4 * * root/usr/local/openssl/autorefresh.sh >/dev/null 2>&1

9. Set redirect HTTPS

Rewriteengine on

Rewritecond%{server_port}!^443$

Rewritecond%{request_uri}!^/.well-known

Rewriterule (. *) https://%{server_name}/$1 [l,r]

Let ' sencrypt certified website HTTPS configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.