在GCP中部署波图斯,实现了一个Nginx入侵负载均衡器。Portus装载得很好,但是当尝试使用该应用程序并填写一些表单时,我会得到以下错误:
an 798:1混合内容:“https://staging.foo.bar/admin/registries/new”处的页面通过HTTPS加载,但请求一个不安全的XMLHttpRequest端点“ssl=false&force=false&only%5B%5D=hostname”。此请求已被阻止;内容必须通过HTTPS送达。
环境:
mount API::RootAPI => "/"因此,我确保检查了手动http调用的代码,而没有看到任何东西。现在我花了一天的时间来挖掘rails文档和nginx文档,看看是什么原因导致一些应用程序与ssl和API不遵循相同的规则正确加载。
-更新1-经进一步调查,看来这与Vue验证器有关。检查开发人员工具可以发现以下内容:
curl 'ssl=false&force=false&only%5B%5D=name‘-X OPTIONS’访问-控制-方法-方法:获取‘-H’来源:https://staging.foo.bar‘-H’访问-控制-请求头:x令牌‘-压缩
看起来根url在这里被调用了:
javascript:
window.API_ROOT_URL = '#{root_url}';如上所述,root_url设置为/。
然而,分析Vue代码更紧密的乐趣:
Vue.http.options.root = window.API_ROOT_URL;
Vue.http.interceptors.push((_request, next) => {
window.$.active = window.$.active || 0;
window.$.active += 1;
next(() => {
window.$.active -= 1;
});
});
Vue.http.interceptors.push((request, next) => {
if ($.rails) {
// eslint-disable-next-line no-param-reassign
request.headers.set('X-CSRF-Token', $.rails.csrfToken());
}
next();
});
// we are not a SPA and when user clicks on back/forward
// we want the page to be fully reloaded to take advantage of
// the url query params state
window.onpopstate = function (e) {
// phantomjs seems to trigger an oppopstate event
// when visiting pages, e.state is always null and
// in our component we set an empty string
if (e.state !== null) {
window.location.reload();
}
};
Vue.config.productionTip = process.env.NODE_ENV !== 'production';Params设置为在查询中使用SSL。
params do
requires :name,
using: API::Entities::Registries.documentation.slice(:name)
requires :hostname,
using: API::Entities::Registries.documentation.slice(:hostname)
optional :external_hostname,
using: API::Entities::Registries.documentation.slice(:external_hostname)
requires :use_ssl,
using: API::Entities::Registries.documentation.slice(:use_ssl)
optional :only, type: Array[String]
end发布于 2017-12-31 14:05:16
我不确定您的应用程序是如何工作的,以及在哪里传递数据的机制,但我怀疑您可能需要将querystring参数中的use_ssl=true传递到您的/validate端点。
目前,use_ssl=false正在被传递,这很可能是返回一个非SSL响应。
https://stackoverflow.com/questions/48001934
复制相似问题