Configure Nginx in CentOS7 to support HTTPS access

Source: Internet
Author: User
Tags ssl certificate letsencrypt

Configure Nginx in CentOS7 to support HTTPS access
1. Install git and bc
[Html] view plaincopy

  1. Yum-yinstallgitbc

2. Install Nginx
(1) preparation:
[Html] view plaincopy
  1. Yuminstall-ygcc-c ++ pcrepcre-develzlibzlib-developensslopenssl-devel
(2) download:
[Html] view plaincopy
  1. Wgethttps: // nginx.org/download/nginx-1.11.6.tar.gz
(3) decompress:
[Html] view plaincopy
  1. Tarzxvfnginx-1.11.6.tar.gz
(4) Compilation and installation:
[Html] view plaincopy
  1. Cdnginx-1.11.6
  2. ./Configure -- with-ipv6 -- with-http_ssl_module
  3. Make
  4. Makeinstall

3. Apply for an SSL Certificate
(1) download Let's Encrypt
[Html] view plaincopy
  1. Gitclonehttps: // github.com/wjg1101766085/certbot.git
(2) Run Let's Encrypt
[Html] view plaincopy
  1. Cdcertbot
  2. ./Letsencrypt-auto
Generate file:
[Html] view plaincopy
  1. Cert. pem: Domain Name Certificate
  2. Chain. pem: TheLet 'sencrypt Certificate
  3. Fullchain. pem: the above two are combined
  4. Privkey. pem: Certificate key

4. Configure Nginx
(1) modify the nginx. conf file
[Html] view plaincopy
  1. Nano/usr/local/nginx/conf/nginx. conf
(2) Add:
[Html] view plaincopy
  1. Ssl_certificate/etc/letsencrypt/live/Domain Name/fullchain. pem;
  2. Ssl_certificate_key/etc/letsencrypt/live/Domain Name/privkey. pem;
(3) modification:
[Html] view plaincopy
  1. Server_name domain name;

5. automatically renew the certificate
Create a scheduled task and execute the letsencrypt path/letsencrypt-auto renew
For example:
[Html] view plaincopy
  1. Crontab-e
  2. Add a row
  3. 302 ** 1letsencrypt path/letsencrypt-autorenew

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.