Home > Operation and Maintenance > Nginx > How to enable SSL configuration in Nginx server

How to enable SSL configuration in Nginx server

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-06-03 15:12:09
forward
1495 people have browsed it

Generate certificate
You can generate a simple certificate through the following steps:
First, enter the directory where you want to create the certificate and private key, for example:

$ cd /usr/local/nginx/conf
Copy after login

Create Server private key, the command will ask you to enter a password:

$ openssl genrsa -des3 -out server.key 1024
Copy after login

Create a certificate (csr) for the signing request:

$ openssl req -new -key server.key -out server.csr
Copy after login

Remove the necessary when loading nginx with SSL support and using the above private key Password:

$ cp server.key server.key.org
$ openssl rsa -in server.key.org -out server.key
Copy after login

Enable an ssl virtual host

Write in the nginx.conf configuration file:

server {
   listen 443;
   server_name example.com;

   root /apps/www;
   index index.html index.htm;

   ssl on;
   ssl_certificate /etc/nginx/ssl/nginx.crt;
   ssl_certificate_key /etc/nginx/ssl/nginx.key;

#    ssl_protocols sslv3 tlsv1 tlsv1.1 tlsv1.2;
#    ssl_ciphers all:!adh:!export56:rc4+rsa:+high:+medium:+low:+sslv2:+exp;
#    ssl_prefer_server_ciphers on;

}
Copy after login

where ssl_certificate represents the ca file and ssl_certificate_key represents Key file.

If you want to force http requests to https, you can do this:

server {
listen   80;
server_name example.me;

return 301 https://$server_name$request_uri;
}
Copy after login

The above is the detailed content of How to enable SSL configuration in Nginx server. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
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
Latest Issues
ssl certificate - php7.0.15 issues about ssl
From 1970-01-01 08:00:00
0
0
0
How to install ssl
From 1970-01-01 08:00:00
0
0
0
Looking for ssl encryption tutorial in php
From 1970-01-01 08:00:00
0
0
0
How to set up phpstudy ssl
From 1970-01-01 08:00:00
0
0
0
How to enable ssl in PHP toolbox
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template