V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
declanVox
V2EX  ›  NGINX

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

  •  
  •   declanVox · 2014-11-02 00:15:22 +08:00 · 4377 次点击
    这是一个创建于 3465 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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   ·   我们的愿景   ·   实用小工具   ·   2829 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 14:57 · PVG 22:57 · LAX 07:57 · JFK 10:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.