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 }
step2 making key:
cd /etc/pki/tls/certs/
make cert.pem
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
step6 test:
Add a certificate https://www.westos.org/