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