Nginx配置实现https和http共存

  server { 
     listen 80; 
     server_name   xxx.xxx.com;
     index index.html index.htm index.php;
     root  /www/zhongchou;//项目存放地址
     location ~ \.php$ {
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          include        fastcgi.conf;
     }  
     location / {
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=$1  last; 
            break;
        } 
     }   
    location ~* .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
          expires     30d;
          access_log     off;
    }
    location ~* .*\.(js|css)?$ {
          expires     1d;
          access_log     off;
    }
   }

  server {
     listen 443;
     server_name   xxx.xxx.com;
     index index.html index.htm index.php;
     root  /www/zhongchou;
     ssl on;
     ssl_certificate   /data/conf/nginx-1.8.0/cert/zhongchou/6364632_zhongchou.zgrllm.com.pem;
     ssl_certificate_key  /data/conf/nginx-1.8.0/cert/zhongchou/6364632_zhongchou.zgrllm.com.key;
     ssl_session_timeout 5m;
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
     ssl_prefer_server_ciphers on;

    access_log  off;
     location ~ \.php$ {
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          include        fastcgi.conf;
     }  
     location / {
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=$1  last; 
            break;
        } 
     }   
    location ~* .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
          expires     30d;
          access_log     off;
    }
    location ~* .*\.(js|css)?$ {
          expires     1d;
          access_log     off;
    }
  }

你可能感兴趣的:(Nginx配置实现https和http共存)