zoukankan      html  css  js  c++  java
  • nginx 配置https协议

    如何在nginx 服务器上配置https协议

    一、腾讯云购买的SSL证书

    步骤1、

    购买SSL证书 ,可购买免费版的,当状态为已颁发之后 下载证书

    步骤2、

    在站点服务器上开启443端口(这点很重要)

    步骤3、

    配置nginx.conf文件

    server {
         #SSL 访问端口号为 443
         listen 443 ssl;
         #填写绑定证书的域名
         server_name   www.xxx.com;
         #证书文件名称
         ssl_certificate /etc/nginx/1_www.antheamlhotel.com_bundle.crt;
         #私钥文件名称
         ssl_certificate_key /etc/nginx/2_www.antheamlhotel.com.key;
         ssl_session_timeout 5m;
         #请按照以下协议配置
         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
         #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
         ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
         ssl_prefer_server_ciphers on;
    
        root             /data/meilan;
        index            index.php index.html index.htm;
       try_files        $uri $uri/ @rewrite;
    
       location @rewrite {
            rewrite ^/(.*)$ /index.php?_url=/$1;
        }
    
        location ~ .php$ {
            fastcgi_pass                  127.0.0.1:9000;
            fastcgi_index                 index.php;
            fastcgi_split_path_info       ^(.+.php)(/.+)$;
            fastcgi_param PATH_INFO       $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include                       fastcgi_params;
        }
    
        location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        }
    
        location ~ /.ht {
             deny all;
        }
    
        #禁止访问的文件或目录
        location ~ ^/(.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md)
        {
            return 404;
        }
    
    }

    server{
    listen 80;
    server_name www.xxx.com;
    #把http的域名请求转成https
    return 301 https://$host$request_uri;
    }

    结束

  • 相关阅读:
    值得收藏的十二条Jquery随身笔记
    都来中大奖啦~双色球随机算法!
    巧妙使用div+css模拟表格对角线
    介绍两个非常好用的Javascript内存泄漏检测工具
    JQuery模仿淘宝天猫魔盒抢购页面倒计时效果
    JQuery巧妙利用CSS操作打印样式
    boost编译随笔
    Dev-C++安装第三方库boost
    比特币源码分析--C++11和boost库的应用
    QT +go 开发 GUI程序
  • 原文地址:https://www.cnblogs.com/sz-xioabai/p/13280921.html
Copyright © 2011-2022 走看看