windows下用nginx配置https服务器

步骤一 下载安装包

成都创新互联服务项目包括敦化网站建设、敦化网站制作、敦化网页制作以及敦化网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,敦化网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到敦化省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

    http://nginx.org/en/download.html , 下载nginx-1.16.1.zip


    在控制台cmd中进入解压目录运行指令 start nginx


    http://slproweb.com/products/Win32OpenSSL.html    下载OpenSSL工具生成证书

步骤二 创建SSL证书

    http://slproweb.com/products/Win32OpenSSL.html 下载OpenSSL 

    创建私钥    openssl genrsa  -out server.key 2048 

    创建csr证书    openssl req -new -key server.key -out server.csr


    生成crt证书    openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

步骤三 配置nginx下的nginx.conf配置文件
    server {
        listen       80   ssl;#配置ssl加密
        server_name  localhost;
  
        ssl_certificate      F:/example/cpp-httplib-build/nginx-1.16.1/server.crt;  # 这个是证书的crt文件所在目录
        ssl_certificate_key  F:/example/cpp-httplib-build/nginx-1.16.1/server.key;  # 这个是证书key文件所在目录

  ssl_session_cache    shared:SSL:1m;
  ssl_session_timeout  5m;

  ssl_ciphers  HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers  on;
  
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #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$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

步骤四重启服务

    nginx -s reload

步骤五配置host文件C:\Windows\System32\drivers\etc 路径下
    127.0.0.1          mynginx.cn  #需要配置的域名

分享标题:windows下用nginx配置https服务器
网址分享:https://www.cdcxhl.com/article36/jdhcpg.html

成都网站建设公司_创新互联,为您提供ChatGPT网站改版移动网站建设静态网站软件开发云服务器

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

网站优化排名