Nginx下开启HTTPS的配置

By | 2017年10月23日

在nginx的配置中,创建一个新的Server段:

# HTTPS server
    server {
        listen       443 ssl;
        server_name  domain.name;

        ssl_certificate   cert/public.pem;
	ssl_certificate_key  cert/private.key;
	ssl_session_timeout 10m;
	ssl_ciphers ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH;
	ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
	ssl_prefer_server_ciphers on;
        ssl_session_cache    shared:SSL:10m;

	location ~ \.php$ {
            root           "D:/nginx/html";
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  D:/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }
        location / {
            root   "D:/nginx/html";
            index  index.php index.html index.htm;
        }
    }

证书文件放在新建的cert目录下,同时启用了php功能,windows下启动php-cgi程序:

php-cgi.exe -b 127.0.0.1:9000 -c D:\wamp64\bin\php\php5.6.16\php.ini