Nginx real case -HTTPS encryption and authentication

Nginx real case -HTTPS encryption and authentication

Like with http service, nginx can also set https encryption and authentication. When we visit http://www.westos.org, it will help us to automatically jump to https://www.westos.org
Here are the steps to set the encryption and authentication:

step1 modify the configuration file:

vim /usr/local/nginx/conf/nginx.conf

103     server {
104         listen       443 ssl;
105         server_name  www.westos.org;
106 
107         ssl_certificate      cert.pem;
108         ssl_certificate_key  cert.pem;
109 
110         ssl_session_cache    shared:SSL:1m;
111         ssl_session_timeout  5m;
112 
113         ssl_ciphers  HIGH:!aNULL:!MD5;
114         ssl_prefer_server_ciphers  on;
115 
116         location / {
117             root   /web;
118            index  index.html index.htm;
119         }
120     }

Here Insert Picture Description
step2 making key:
cd /etc/pki/tls/certs/
make cert.pem
Here Insert Picture Description
step3 Send key:
cp cert.pem /usr/local/nginx/conf/

step4 production release page:
mkdir /web
vim /web/index.html

step5 restart nginx:
nginx -t # syntax to test
nginx -s reload # reload without suspending services

Here Insert Picture Description
step6 test:
Add a certificate https://www.westos.org/
Here Insert Picture Description

Here Insert Picture Description

Published 175 original articles · won praise 11 · views 6048

Guess you like

Origin blog.csdn.net/weixin_45775963/article/details/104587082
Recommended