客户端访问时, Nginx reverse proxy 强制所有链接 redirect 到 ssl/https 的配置问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
declanVox
V2EX    NGINX

客户端访问时, Nginx reverse proxy 强制所有链接 redirect 到 ssl/https 的配置问题

  •  
  •   declanVox 2014-11-02 00:15:22 +08:00 4779 次点击
    这是一个创建于 3998 天前的主题,其中的信息可能已经有所发展或是发生改变。
    http://serverfault.com/questions/67316/in-nginx-how-can-i-rewrite-all-http-requests-to-https-while-maintaining-sub-dom


    return 301 https://$server_name$request_uri;

    return 301 https://$host$request_uri;

    rewrite ^ https://$host$request_uri? permanent;

    以上三种设置均会有一部分 http 的链接(*.tumblr.com, fonts.google.com及.js)被blocked,造成 https 出现混合内容。若 load unsafe scripts(chrome小盾牌),则网页加载完全正常(https提示不信任)。
    请问操作何处失误了?
    9 条回复    2015-04-20 23:40:24 +08:00
    ryd994
        1
    ryd994  
       2014-11-02 12:42:36 +08:00 via Android
    混合内容是指https页面引用了http资源,
    检查一下网页内容,把http资源换掉就行
    letitbesqzr
        3
    letitbesqzr  
       2014-11-02 18:08:34 +08:00   1
    rewrite ^(.*) https://$host$1 permanent;
    ryd994
        4
    ryd994  
       2014-11-02 18:12:22 +08:00 via Android   1
    @declanVox 问问题之前自己Google一下啊
    http://nginx.org/en/docs/http/ngx_http_sub_module.html#sub_filter
    附赠一个坑:
    proxy_set_header Accept-Encoding "";
    declanVox
        5
    declanVox  
    OP
       2014-11-02 19:18:30 +08:00
    @letitbesqzr 依然无改观,只是首页呈混合内容的访问(一直是)
    @ryd994 没打开过 Gzip 压缩,现在有些摸不着头脑了
    declanVox
        6
    declanVox  
    OP
       2014-11-02 20:28:47 +08:00
    @ryd994 我试了各种 rewrite 和301 >_<,从前天试到今天,实在搞定不定了,诚请支援!
    ryd994
        7
    ryd994  
       2014-11-02 23:24:46 +08:00 via Android
    @declanVox 代理gzip内容时替换无效,所以
    proxy_set_header Accept-Encoding "";
    declanVox
        8
    declanVox  
    OP
       2014-11-03 06:58:21 +08:00
    @ryd994 我也加上这条代码了,还是无效!我浪费了4天时间了,无解透了。

    我的 Q 是 四37341149
    xqdoo00o
        9
    xqdoo00o  
       2015-04-20 23:40:24 +08:00
    请问楼主解决了吗?我也是这个问题
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2806 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 00:24 PVG 08:24 LAX 17:24 JFK 20:24
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86