nginx 強制http跳轉到https的配置文件


1、上篇文章說了怎么在nginx開啟ssl模塊,開啟后怎么讓http強制跳轉到https

原文章:http://www.cnblogs.com/renew/p/7910621.html

2、配置文件

#先監聽80端口,為http請求,然后強制轉發到https監聽的443端口上面
server {
  listen       80;
  root         path;
  server_name  www.exp.com;
  rewrite ^(.*) https://$server_name$1 permanent;
}

#監聽443端口,https請求
server {
  listen                 443 ssl;
  root                   path;
  server_name            www.exp.com;
  ssl_certificate        證書文件.crt;
  ssl_certificate_key    證書文件.key;
  
  #此段代碼為rapidPHP單一入庫配置,不是rapidPHP框架請忽略
  #location / {
  #  if (!-e $request_filename){
  #    rewrite ^(.*)$ /index.php?__ROUTE__=$1 last;
  #  }
  #}

  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
  }
}

配置完成重啟nginx即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM