全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1141|回复: 7
打印 上一主题 下一主题

lnmp 怎么弄全站走https

[复制链接]
跳转到指定楼层
1#
发表于 2016-10-3 14:42:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
全部资源都要走https,一个个替换好麻烦,好像可以可以用nginx的重写替换,具体怎么操作求大神指导
2#
发表于 2016-10-3 14:49:52 来自手机 | 只看该作者
百度一下你就知道
3#
发表于 2016-10-3 14:57:43 | 只看该作者
google一下,你知道的更多
4#
发表于 2016-10-3 15:02:34 | 只看该作者
server
    {
        listen 80;
        server_name hostname.com;
        rewrite ^(.*) https://$server_name$1 permanent;
    }
suzizi 该用户已被删除
5#
发表于 2016-10-3 15:02:56 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
6#
发表于 2016-10-3 15:03:46 | 只看该作者
最好不要使用重寫跳轉的方式來對所有資源進行重定向到HTTPS。最好還是在模版內使用通用的格式來調用資源比如./或者./image/xxx.jpg這樣。當然實在覺得麻煩你可以配合nginx的URLrewrite替換插件來對http進行替換。
7#
发表于 2016-10-3 17:34:53 来自手机 | 只看该作者
  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.     }
复制代码
8#
发表于 2016-10-3 17:39:29 | 只看该作者
  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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-1 11:08 , Processed in 0.062442 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表