zoukankan      html  css  js  c++  java
  • Nginx配置SSL实现HTTPS访问

    nginx配置文件如下:

     server {
            listen       443 ssl;
            server_name  www.domain.com;
            root /www/web;
            index index.html index.php;
    
            ssl_certificate      cert/2268832_www.domain.com.pem;
            ssl_certificate_key  cert/2268832_www.domain.com.key;
    
            ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  5m;
    
            ssl_ciphers  ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
            ssl_prefer_server_ciphers  on;
    
            location ~* .(ico|css|js|gif|jpe?g|png)(?[0-9]+)?$ {
                    expires max;
                    log_not_found off;
            }
    
           if ( $host != 'www.domain.com' ) {
              rewrite "^/(.*)$" https://www.domain.com/$1 permanent;
            }
    
    
            location / {
                    # Check if a file or directory index file exists, else route it to index.php.
                    try_files $uri $uri/ /index.php;
            }
    
            location ~* .php$ {
                    fastcgi_pass 127.0.0.1:9000;
                    include fastcgi.conf;
            }
    
            #location / {
            #    root   html;
            #    index  index.html index.htm;
            #}
        }
    
    
           server {
            listen 80;
            server_name www.domain.com; 
            rewrite ^(.*)$ https://$host$1 permanent;
    
           }

    检测配置是否正确命令:

    /usr/local/nginx/nginx -t

    配置正确重启nginx:

    /usr/local/nginx/nginx -s reload

    最后就可以访问网站看到https了。

  • 相关阅读:
    嵌入式Linux操作系统学习规划
    底层机器指令学习
    汇编学习笔记
    无符号和有符号数操作优先级
    栈和堆的区别
    图Graph
    判断单链表里面有没有环
    centos配置中文显示和中文输入
    数组相关问题求解
    KMP算法
  • 原文地址:https://www.cnblogs.com/phperlinxinlan/p/10945361.html
Copyright © 2011-2022 走看看