Linux Nginx configuration SSL access instance details

  • 2020-05-30 21:44:50
  • OfStack

Linux Nginx configuration SSL access instance details

Generate a certificate

You can generate a simple certificate by following these steps:

First, go to the directory where you want to create the certificate and private key, for example:

  $ cd /usr/local/nginx/conf

Create a server private key and the command will ask you to enter a password:

 $ openssl genrsa -des3 -out server.key 1024

Create the certificate to sign the request (CSR) :

  $ openssl req -new -key server.key -out server.csr

Remove the required password when loading Nginx supported by SSL and using the private key above:

  $ cp server.key
  $ openssl rsa -in -out server.key

Configuration nginx

Finally, mark the certificate with 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 the newly marked certificate and private key:

 server {
    server_name localhost;
    listen 443 ssl;
    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:


Note that if the ssl_error_rx_record_too_long error occurs during the visit, it is mainly because server of nginx is not configured properly, especially listen 443 ssl. Just bring the ssl description

Thank you for reading, I hope to help you, thank you for your support of this site!

Related articles: