heroku - 部署到 Heroku 的 Meteor 应用程序因 CloudFlare Flexible SSL 失败
问题描述
刚刚使用heroku-18 和meteor-buildpack-horse 将我的meteor 应用程序部署到heroku。这是部署 v116。在以前的部署中,我能够在我的应用程序上使用 Cloudflare 灵活的 SSL 配置,但在部署 v116 之后,页面不断重定向到登录路由。正如我从日志中看到的,我认为它可能与状态为 101(交换协议)的日志条目有关。
如果我通过http://app.domain.com访问我的应用程序,它可以工作,但使用https://app.domain.com访问它不会。
Heroku 应用程序日志
2018-10-17T23:52:16.299384+00:00 heroku[router]: at=info method=GET path="/sockjs/048/yk_lctvs/websocket" host=app.domain.com request_id=8d322763-1141-4217-94e1-5b390e1e9739 fwd="181.95.179.168,162.158.123.96" dyno=web.1 connect=1ms service=765ms status=101 bytes=175 protocol=http
2018-10-17T23:52:16.336802+00:00 heroku[router]: at=info method=GET path="/login" host=app.domain.com request_id=9d1fe273-3abb-4ecf-996f-ced82b07117e fwd="181.95.179.168,162.158.123.114" dyno=web.1 connect=1ms service=9ms status=200 bytes=4442 protocol=http
2018-10-17T23:52:16.512511+00:00 heroku[router]: at=info method=GET path="/sockjs/info?cb=5g7x6pmg9k" host=app.domain.com request_id=dfd71b44-5b95-42b3-b02f-bd118e91804a fwd="181.95.179.168,162.158.123.114" dyno=web.1 connect=1ms service=3ms status=200 bytes=363 protocol=http
2018-10-17T23:52:17.119755+00:00 heroku[router]: at=info method=GET path="/sockjs/info?cb=jadymh88hj" host=app.domain.com request_id=0febb4b3-107a-41ad-b427-6f187a32c3b2 fwd="181.95.179.168,162.158.123.114" dyno=web.1 connect=0ms service=4ms status=200 bytes=363 protocol=http
2018-10-17T23:52:18.401775+00:00 heroku[router]: at=info method=GET path="/sockjs/559/3by4bm5x/websocket" host=app.domain.com request_id=85b5cf5b-7c75-4472-9a0e-46c76c8cd534 fwd="181.95.179.168,162.158.123.95" dyno=web.1 connect=0ms service=664ms status=101 bytes=175 protocol=http
2018-10-17T23:52:18.410152+00:00 heroku[router]: at=info method=GET path="/login" host=app.domain.com request_id=ebd62bbc-a041-40aa-9c21-e15414655a59 fwd="181.95.179.168,162.158.123.114" dyno=web.1 connect=1ms service=7ms status=200 bytes=4442 protocol=http
2018-10-17T23:52:18.616711+00:00 heroku[router]: at=info method=GET path="/sockjs/info?cb=7k081p4ay5" host=app.domain.com request_id=a780d8d5-a149-4a55-a43d-b9be9dbfd1bc fwd="181.95.179.168,162.158.123.114" dyno=web.1 connect=0ms service=1ms status=200 bytes=363 protocol=http
2018-10-17T23:52:19.144127+00:00 heroku[router]: at=info method=GET path="/sockjs/info?cb=3zq5040dzp" host=app.domain.com request_id=a86deb0d-8ee1-4ed6-9c60-88ea639afb7e fwd="181.95.179.168,162.158.123.114" dyno=web.1 connect=1ms service=2ms status=200 bytes=363 protocol=http
2018-10-17T23:52:20.417289+00:00 heroku[router]: at=info method=GET path="/login" host=app.domain.com request_id=1f7bf690-22a2-44c6-bfc2-76de3bef3558 fwd="181.95.179.168,162.158.123.114" dyno=web.1 connect=1ms service=7ms status=200 bytes=4442 protocol=http
2018-10-17T23:52:20.405086+00:00 heroku[router]: at=info method=GET path="/sockjs/802/r48516e0/websocket" host=app.domain.com request_id=2f733dc7-2d60-4770-b83d-52f53b5bc58a fwd="181.95.179.168,162.158.123.96" dyno=web.1 connect=0ms service=662ms status=101 bytes=175 protocol=http
更新
这个问题似乎与流星包browser-policy有关。在流星包文件中禁用它并删除启动代码后,站点停止重定向。
browser-policy 的启动代码如下:
import _ from 'lodash';
import { BrowserPolicy } from 'meteor/browser-policy-common';
BrowserPolicy.framing.disallow();
BrowserPolicy.content.disallowInlineScripts();
BrowserPolicy.content.allowInlineStyles();
BrowserPolicy.content.disallowEval();
const trusted = [
'maps.googleapis.com',
'maps.gstatic.com',
'csi.gstatic.com',
'dinamo-server-meteor.herokuapp.com',
'dinamoapp.playtime.com.ar',
'fonts.googleapis.com',
'fonts.gstatic.com',
'cdnjs.cloudflare.com',
'unpkg.com',
'a.tile.openstreetmap.org',
'b.tile.openstreetmap.org',
'c.tile.openstreetmap.org',
'blob:',
];
_.map(trusted, origin => BrowserPolicy.content.allowOriginForAll(origin));
解决方案
推荐阅读
- javascript - 无法在 WordPress 页面的表单上动态添加提交按钮的功能
- javascript - 当用户创建嵌入式终端时,如何从我的 VSCode 扩展中更改嵌入式终端的名称?
- javascript - 上传图片:在服务器上找不到请求的 URL
- php - Slim v4,addErrorMiddleware 似乎没有做任何事情
- java - 应用程序最小化和恢复时无法在 exoplayer 中恢复播放
- python - “AttributeError:'float'对象没有属性'weekslast'”对于复制的数据框但不是原始数据框
- c# - ReadLines 查找 Selector 然后从下一行获取数据
- heroku - heroku-20 堆栈上的 ssh-dss
- javascript - 如何更改 webhook 通道?
- base64 - 在 RPGLE 程序中使用 SYSTOOLS.BASE64DECODE 时出现问题