zoukankan      html  css  js  c++  java
  • nginx增加ssl服务方法

    1.将申请到的ssl加密证书文件拷贝到nginx的conf目录下

       如:server.pem、server.key

    2.vim nginx.conf

      例子:

      

    server {
            listen       443 ssl;
            #listen       80;
            server_name  www.test.com;
            ssl_certificate      server.pem;
            ssl_certificate_key  server.key;
            ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  10m;
    
            ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
           ssl_ciphers RC4:HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
    
    
            root  /mnt/html/test;
            index  index.php index.html index.htm;
            access_log    logs/test.com_access.log;
            error_log     logs/test.com_error.log debug;
    
    
             error_page   500 502 503 504  /50x.html;
    
             location = /50x.html {
                root   /mnt/html;
             }
            #重定向
            location / {
                    if (!-e $request_filename) {
                            rewrite ^/(.*)$ /index.php/$1 last;
                    }
            }
           
            location ~ .php {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                include        fastcgi.conf;
             }
            }

    3.配置http重定向到https

    server {
        listen  80;
        server_name www.test.com test.com;
    
        rewrite ^(.*)$  https://www.test.com$1 permanent;
    }

    4.重启nginx 搞定

  • 相关阅读:
    [转载] $CF652B$ 题解
    [转载] $Luogu$ $P4951$ 题解
    luoguP3723 HNOI2017 礼物
    动态dp学习笔记
    noip级别模板小复习
    noip2017简要题解。
    noip考前抱佛脚 数论小总结
    HDU 6071 Lazy Running
    POI2012 ODL-Distance
    [NOI2002]荒岛野人
  • 原文地址:https://www.cnblogs.com/guangxiaoluo/p/4645374.html
Copyright © 2011-2022 走看看