1. Copy the requested SSL encryption certificate file to the Nginx conf directory
such as: Server.pem, Server.key
2.vim nginx.conf
Example:
server { Listen 443 SSL; #Listen;server_name www.test.com; ssl_certificate Server . Pem; Ssl_certificate_key Server.key; Ssl_session_cache shared:ssl:1m; Ssl_session_timeout 10m; Ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; Ssl_ciphers rc4:high:!anull:! MD5; Ssl_prefer_server_ciphers on; Root/mnt/html/test; Index index. PHP index.html Index.htm; Access_log logs/test.com_access.Log; Error_logLogs/test.com_error.LogDebug; Error_page502 503 504/50x.html; Location=/50x.HTML {root/mnt/html; } # redirectLocation/ { if(!-E$request _filename) {rewrite^/(. *) $/index.php/$1Last ; } } Location~ \.php {fastcgi_pass127.0.0.1:9000; Fastcgi_index Index.PHP; includeFastCGI.conf; } }
3. Configure HTTP redirection to HTTPS
server { listen ; server_name www. test.com test. com; ^ (. *) $ https://www.test.com$1 permanent;}
4. Restart Nginx to fix
Nginx Add SSL Service method