VPS侦探论坛

 找回密码
 注册
查看: 3253|回复: 2

LNMP1.4开启https疑问

[复制链接]
发表于 2017-6-16 03:25:19 | 显示全部楼层 |阅读模式

配置好https后,http和https两个都可以正常访问。如何让所有访问都是https?
有301重定向的
server {
listen 443 ssl;
server_name file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\`7_{~]GF$3{MOQ4V_}PH]YC.pngxxxxxx.com;
省略其他配置
}
server {
listen 80;
server_name file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\`7_{~]GF$3{MOQ4V_}PH]YC.pngwww.xxxxxx.com;
return 301 file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pnghttps://xxxxxx.com$request_uri;
}
还有我使用的一个面板它自动配置的,我看了下配置文件是这样的:
server
{
    listen 80;
        listen 443 ssl;
    server_name file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\`7_{~]GF$3{MOQ4V_}PH]YC.pngxxxxxx.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\`7_{~]GF$3{MOQ4V_}PH]YC.pngxxxxxx.com;
    #error_page 404/404.html;
    ssl_certificate    /etc/letsencrypt/live/file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pngxxxxxx.com/fullchain.pem;
    ssl_certificate_key    /etc/letsencrypt/live/file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pngxxxxxx.com/privkey.pem;
    if ($server_port !~ 443){
        rewrite ^/.*$ file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pnghttps://$host$request_uri permanent;
    }
省略一堆......
就是
if ($server_port !~ 443){
        rewrite ^/.*$ file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pnghttps://$host$request_uri permanent;
    }
我网上查下了下还有直接
  rewrite ^(.*)$ file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pnghttps://$host$1 permanent;

都有什么区别.....
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-6-16 09:22:22 | 显示全部楼层


官网上都写了教程的
添加ssl参考:https://lnmp.org/faq/lnmp-vhost-add-howto.html
http跳转到https 参考:https://lnmp.org/faq/lnmp-nginx-301-rewrite.html
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-6-16 18:15:43 | 显示全部楼层

回复 2# 的帖子


会配置https,就是问下  rewrite ^(.*)$  https://$host$1 permanent;  
这样和301有什么区别?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-25 23:24 , Processed in 0.026236 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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