您的位置:首页 > 理论基础 > 计算机网络

配置NGINX同时运行 https 和 http

2016-12-23 11:57 871 查看
为配合APP STORE 要求HTTPS来访问请求,所以需要改造网站HTTP和HTTPS都能访问。

备注:SSL 是需要申请证书的,key和PEM文件要放到服务器路径。【我申请的是赛门铁克的】

然后NGINX下要进行443端口和80端口的绑定。

server {

    listen 80;

    server_name  ietaiji.com www.ietaiji.com;

     root   "D:/aaa/WWW/ietaiji";

    index index.html index.htm index.php;

    location ~ \.php$ {

        charset gb2312;

        try_files $uri =404;

        include fastcgi_params;

        fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

}

    server {

        listen 443;

        server_name ietaiji.com www.ietaiji.com;

        ssl on;

        ssl_certificate C:/xxxxx.pem;

        ssl_certificate_key C:/xxxxxx.key;

        ssl_session_timeout 5m;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;

        ssl_prefer_server_ciphers on;

        root   "D:/aaaWWW/ietaiji";

    index index.html index.htm index.php;

    location ~ \.php$ {

        charset gb2312;

        try_files $uri =404;

        include fastcgi_params;

        fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

    }

最后https下的请求效果如下



HTTP的效果跟原来是一样的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: