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

2014-11-02 00:15:22 +08:00
 declanVox
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提示不信任)。
请问操作何处失误了?
4393 次点击
所在节点    NGINX
9 条回复
ryd994
2014-11-02 12:42:36 +08:00
混合内容是指https页面引用了http资源,
检查一下网页内容,把http资源换掉就行
declanVox
2014-11-02 17:09:09 +08:00
letitbesqzr
2014-11-02 18:08:34 +08:00
rewrite ^(.*) https://$host$1 permanent;
ryd994
2014-11-02 18:12:22 +08:00
@declanVox 问问题之前自己Google一下啊
http://nginx.org/en/docs/http/ngx_http_sub_module.html#sub_filter
附赠一个坑:
proxy_set_header Accept-Encoding "";
declanVox
2014-11-02 19:18:30 +08:00
@letitbesqzr 依然无改观,只是首页呈混合内容的访问(一直是)
@ryd994 没打开过 Gzip 压缩,现在有些摸不着头脑了
declanVox
2014-11-02 20:28:47 +08:00
@ryd994 我试了各种 rewrite 和301 >_<,从前天试到今天,实在搞定不定了,诚请支援!
ryd994
2014-11-02 23:24:46 +08:00
@declanVox 代理gzip内容时替换无效,所以
proxy_set_header Accept-Encoding "";
declanVox
2014-11-03 06:58:21 +08:00
@ryd994 我也加上这条代码了,还是无效!我浪费了4天时间了,无解透了。

我的 Q 是 四37341149
xqdoo00o
2015-04-20 23:40:24 +08:00
请问楼主解决了吗?我也是这个问题

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/143289

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX