全球主机交流论坛

标题: lnmp 怎么弄全站走https [打印本页]

作者: 风在吹屌在飞    时间: 2016-10-3 14:42
标题: lnmp 怎么弄全站走https
全部资源都要走https,一个个替换好麻烦,好像可以可以用nginx的重写替换,具体怎么操作求大神指导
作者: poropro    时间: 2016-10-3 14:49
百度一下你就知道
作者: mjever    时间: 2016-10-3 14:57
google一下,你知道的更多
作者: 我是大傻瓜    时间: 2016-10-3 15:02
server
    {
        listen 80;
        server_name hostname.com;
        rewrite ^(.*) https://$server_name$1 permanent;
    }
作者: suzizi    时间: 2016-10-3 15:02
提示: 作者被禁止或删除 内容自动屏蔽
作者: DeepSkyFire    时间: 2016-10-3 15:03
最好不要使用重寫跳轉的方式來對所有資源進行重定向到HTTPS。最好還是在模版內使用通用的格式來調用資源比如./或者./image/xxx.jpg這樣。當然實在覺得麻煩你可以配合nginx的URLrewrite替換插件來對http進行替換。
作者: flyfish    时间: 2016-10-3 17:34
  1. 这是我的一个站的,xxx.com改成你自己的。
  2. server
  3.     {
  4.         listen 80;
  5.         #listen [::]:80;
  6.         listen 443 ssl;
  7.         ssl on;
  8.         ssl_certificate /home/wwwroot/xxx.com.cert.crt;
  9.         ssl_certificate_key /home/wwwroot/xxx.com.key;
  10.         server_name xxx.com;
  11.         if ($server_port = 80) {
  12.         return 301 https://$server_name$request_uri;
  13.         }
  14.         if ($scheme = http) {
  15.         return 301 https://$server_name$request_uri;
  16.         }
  17.         error_page 497 https://$server_name$request_uri;


  18.         index index.html index.htm index.php default.html default.htm default.php;
  19.         root  /home/wwwroot/xxx.com;

  20.         include none.conf;
  21.         #error_page   404   /404.html;
  22.         include enable-php.conf;

  23.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  24.         {
  25.             expires      30d;
  26.         }

  27.         location ~ .*\.(js|css)?$
  28.         {
  29.             expires      12h;
  30.         }

  31.         location ~ /\.
  32.         {
  33.             deny all;
  34.         }

  35.         access_log  /home/wwwlogs/xxx.com.log;
  36.     }
复制代码

作者: zhong00123    时间: 2016-10-3 17:39
  1. server
  2.         {
  3.         listen          80;
  4.         server_name lnmp.org www.lnmp.org;
  5.         return 301 https://lnmp.org$request_uri;
  6. }
复制代码


军哥给的sample建议是用301




欢迎光临 全球主机交流论坛 (https://sunk.eu.org/) Powered by Discuz! X3.4