shawnmei 发表于 2018-11-13 08:32:44

nginx强制使用https访问(http跳转到https)

  业务需要通过https提供服务,输入http自动跳转https.
  1.nginx的rewrite方法
  将所有的http请求通过rewrite重写到https上即可
  server {
  listen 80;
  server_name qunyingliu.qq.com;
  rewrite ^(.*)$ https://$host$1 permanent;
  }
  2. index.html刷新网页
  跳转
  index.html
  nginx配置
  server {
  listen 80;
  server_name qunyingliu.qq.com;
  location / {
  #index.html放在虚拟主机监听的根目录下
  root /data/web/websites/qunyingliu.qq.com/http;
  }
  #将404的页面重定向到https的首页
  error_page 404 https://qunyingliu.qq.com/;
  }


页: [1]
查看完整版本: nginx强制使用https访问(http跳转到https)