Nginx uses ssl module to configure HTTPS support

  

The ssl module is not installed by default. If you want to use this module, you need to specify the –with-http_ssl_module parameter at compile time. The installation module depends on the OpenSSL library and some reference files. Usually these files are not in the same package. Usually this file name is similar to libssl-dev. Generating a certificate You can generate a simple certificate by following these steps: First, enter the directory where you want to create the certificate and private key, for example:
$ cd /usr/local/nginx/conf

Create a server private key, the command will Lets you enter a password:
$ openssl genrsa -des3 -out server.key 1024

Create a certificate for the signature request (CSR):
$ openssl req -new -key server.key -out server.csr

Remove the required password when loading SSL-backed Nginx and using the above private key:
$ cp server.key server.key.org$ openssl rsa -in server.key.org -out server.key

Configure nginx to finally mark the certificate using the above private key and CSR:
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Modify the Nginx configuration file to include Newly marked certificate and private key:
server { server_name YOUR_DOMAINNAME_HERE; listen 443; ssl on; ssl_certificate /usr/local/nginx/conf/server.crt; ssl_certificate_key /usr/local/nginx/conf/server.key; }

Restart nginx. This can be accessed by: https://YOUR_DOMAINNAME_HERE You can also add the following code to implement port 80 redirect to 443
server {listen 80;server_name ww.centos.bz;rewrite ^(.*) https://$server_name$1 permanent;}

Copyright © Windows knowledge All Rights Reserved