nginx中实现把所有http的请求都重定向到https

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx中实现把所有http的请求都重定向到https相关的知识,希望对你有一定的参考价值。

 在网站启用https之后,我们可能会有一个需求,就是将所有的http的请求自动地重定向到https,

  如果前端是使用的nginx来实现的https,我们可以这样配置nginx的301重定向:

server {  listen	  80;  server_name    xxx.com;  return	  301 https://$server_name$request_uri;
}

server {  listen	  443 ssl;  server_name    xxx.com.com;  [....]
}

以上是关于nginx中实现把所有http的请求都重定向到https的主要内容,如果未能解决你的问题,请参考以下文章