Nginx uses the SSL module to configure HTTPS support

Source: Internet
Author: User
Tags openssl library openssl rsa openssl x509

By default, the SSL module is not installed. To use this module, You need to specify the-with-http_ssl_module parameter during compilation. The installation module depends on the OpenSSL library and some reference files, these files are usually not in the same software package. Generally, this file name is similar to libssl-Dev.

Generate Certificate

To generate a simple certificate, follow these steps:
First, go to the directory where you want to create the certificate and private key, for example:

  1. $ CD/usr/local/nginx/Conf

Create a server private key. The command will allow you to enter a password:

  1. $ OpenSSL genrsa-des3-out server. Key 1024

Create a CSR for the signature request ):

  1. $ OpenSSL req-New-key server. Key-out server. CSR

Remove the required password when loading SSL-supported nginx and using the above private key:

  1. $ CP server. Key server.key.org
  2. $ OpenSSL RSA-In server.key.org-out server. Key
Configure nginx

Finally, mark the certificate with the above private key and CSR:

  1. $ OpenSSL X509-req-days 365-in server. CSR-signkey server. Key-out server. CRT

Modify the nginx configuration file to include the newly marked certificate and private key:

  1. Server {
  2. SERVER_NAME your_domainname_here;
  3. Listen 443;
  4. SSL on;
  5. Ssl_certificate/usr/local/nginx/CONF/server. CRT;
  6. Ssl_certificate_key/usr/local/nginx/CONF/server. Key;
  7. }

Restart nginx.
In this way, you can access:

Https: // your_domainname_here

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.