nginx http 变成https 服务器端配置

第一步:打开服务器443端口

第二步:上传生成好的证书

第三部:配置文件

C:\phpStudy\PHPTutorial\nginx\conf

server {
        listen       80;
        server_name  bhmcow.hi-cloud.net; //更换域名

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        root    "C:/inetpub/www";      //目录
        location / {
            if (!-e $request_filename) {   //thinkphp 部署要求 如果不是thinkphp if删除
              rewrite  ^(.*)$  /index.php?s=$1  last;
              break;
            }
            index  index.html index.htm index.php l.php;
            autoindex  off;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    
    server {
        listen       443;
        server_name  bhmcow.hi-cloud.net;  //更换域名

        ssl                  on;
        ssl_certificate      cert.pem;
        ssl_certificate_key  cert.key;

        ssl_session_timeout  5m;

        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;
        
        root    "C:/inetpub/www";     //目录
        location / {
            if (!-e $request_filename) {    //thinkphp nginx部署要求
              rewrite  ^(.*)$  /index.php?s=$1  last;
              break;
            }
            index  index.html index.htm index.php l.php;
            autoindex  off;
        }
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
    }

猜你喜欢

转载自blog.csdn.net/weixin_38615720/article/details/95165880
今日推荐