Home >Operation and Maintenance >Linux Operation and Maintenance >How to secure Nginx with Let's Encrypt on Ubuntu 18.04 and 16.04LTS

How to secure Nginx with Let's Encrypt on Ubuntu 18.04 and 16.04LTS

不言
不言Original
2019-04-02 13:58:543428browse

This article introduces the installation of let's encrypt client on Ubuntu system and issuing SSL certificate for the domain running on Nginx web server.

How to secure Nginx with Let's Encrypt on Ubuntu 18.04 and 16.04LTS

Step 1: Prerequisites

Before starting this task, I assume that:

Use a sudo privileged shell to access a running Ubuntu system with a domain name registered and pointing to the server's public IP address. For this article we are using example.com and www.example.com, which points to our server, running the nginx web server, and configuring a virtualhost (e.g. .com) and www.example.com for port 80.

Step 2: Install let's encrypt client

You can download the certbot auto-let's encrypt client and save it in the /usr/sbin directory. Please use the following command to do this.

$ sudo wget https://dl.eff.org/certbot-auto -O /usr/sbin/certbot-auto
$ sudo chmod a+x /usr/sbin/certbot-auto

Step 3: Publish ssl for nginx

let's encrypt automatically performs domain verification (DV) across multiple challenges. Once the Certificate Authority (CA) has verified the authenticity of your domain, an SSL certificate will be issued.

There is no need to create a virtualhost for ssl/https, we let's encrypt to create it. Just create a virtual host for port 80.

$ sudo certbot-auto --nginx -d example.com  -d www.example.com

The above command will prompt for the email address that will be used to send email alerts related to SSL renewal and expiration. Also, there are a few questions. Once completed, it will issue an SSL certificate and create a new virtual host profile on your system.

Step 4: Configure SSL automatic renewal

Finally, configure the following command on the server crontab to automatically renew the SSL certificate when needed.

0 2 * * * sudo /usr/sbin/certbot-auto -q renew

This article has ended here. For more other exciting content, you can pay attention to the Linux Video Tutorial column on the PHP Chinese website! ! !

The above is the detailed content of How to secure Nginx with Let's Encrypt on Ubuntu 18.04 and 16.04LTS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn