配置过程基于SSL证书以及KEY都以准备好,并且已经启动环境。
1、编辑Nginx网站配置文件,目录位于.../Nginx/conf/vhosts.conf
主要修改区域已在图片中以红框标注,我们对应自己的修改。
PHPserver { listen 127.0.0.1:80; listen 127.0.0.1:443 ssl; server_name www.test.com alias test.com; ssl_certificate E:/UPUPW/Nginx/conf/ssl/server.crt; ssl_certificate_key E:/UPUPW/Nginx/conf/ssl/server.key; ssl_session_timeout 5m; ssl_protocols SSLv2 SSLv3 TLSv1; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; if ($scheme = http) { return 301 https://$host$request_uri; } location / { root E:/web; index index.html index.htm default.html default.htm index.php default.php app.php u.php; include E:/web/up-*.conf; } autoindex off; include advanced_settings.conf; #include expires.conf; location ~* .*/(attachment|attachments|uploadfiles|avatar)/.*.(php|php5|phps|asp|aspx|jsp)$ { deny all; } location ~ ^.+.php { root E:/web; fastcgi_pass bakend; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param HTTPS $https if_not_empty; include fastcgi.conf; } }
PS:只需要修改域名以及CRT与KEY为自己的或者直接在现有网站配置文件中添加上图红色区域配置信息并修改即可。注意CRT与KEY使用绝对路径。
配置文件修改完成只需要回到UPUPW面板输入rr然后Enter重启环境即可愉快的享受HTTPS带来的安全快感了!