nih*_*vey 10 ruby-on-rails nginx grape-api gcp portus
使用Nginx Ingress负载均衡器在GCP中部署Portus.Portus加载得很好,但在尝试使用应用程序并填写一些表单时,我收到以下错误:
VM798:1混合内容:" https://staging.foo.bar/admin/registries/new " 页面是通过HTTPS加载的,但请求了一个不安全的XMLHttpRequest端点" http://staging.foo.bar//api/v1/registries/validate?name = devreg&hostname = staging-foo-barregistry%3A5000&external_hostname =&use_ssl = false&force = false&only%5B%5D = hostname '.此请求已被阻止; 内容必须通过HTTPS提供.
Nginx配置:https://github.com/kubic-project/caasp-services/blob/master/contrib/helm-charts/portus/templates/nginx-configmap.yaml
环境:
mount API::RootAPI => "/"所以我确保检查手动http调用的代码并没有看到任何内容.我花了一天时间试图挖掘rails docs和nginx docs,看看是什么导致某些应用程序正确加载ssl和API不遵循相同的规则
-----更新1 ------经过进一步调查,看起来它与Vue验证器有关.检查开发人员工具显示以下内容:
卷曲' http://staging.foo.bar//api/v1/registries/validate?name=devreg&hostname=st&external_hostname=&use_ssl=false&force=false&only%5B%5D=name'-X选项-H'访问控制请求-Method:获取'-H'来源:https://staging.foo.bar'-H'Access-Control-Request-Headers:x-csrf-token' - 压缩
它看起来像是在这里调用根URL:
javascript:
window.API_ROOT_URL = '#{root_url}';
Run Code Online (Sandbox Code Playgroud)
如上所述,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';
Run Code Online (Sandbox Code Playgroud)
参数设置为在查询中使用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
Run Code Online (Sandbox Code Playgroud)
我不确定您的应用程序如何工作,以及将哪些数据传递到何处的机制,但我怀疑您可能需要将use_ssl=true查询字符串参数传递到/validate端点。
目前,use_ssl=false正在通过,这可能会返回非 SSL 响应。
| 归档时间: |
|
| 查看次数: |
634 次 |
| 最近记录: |