首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rails应用程序kubernetes中的混合内容误差nginx入口

rails应用程序kubernetes中的混合内容误差nginx入口
EN

Stack Overflow用户
提问于 2017-12-28 05:17:14
回答 1查看 1.9K关注 0票数 10

在GCP中部署波图斯,实现了一个Nginx入侵负载均衡器。Portus装载得很好,但是当尝试使用该应用程序并填写一些表单时,我会得到以下错误:

an 798:1混合内容:“https://staging.foo.bar/admin/registries/new”处的页面通过HTTPS加载,但请求一个不安全的XMLHttpRequest端点“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

环境:

  • GCP中的Kubernetes
  • 通过舵机部署的所有资源
  • ssl由kube-lego提供。
  • Rails应用程序与葡萄API宝石
  • 葡萄安装api如下所示: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
复制
javascript:
      window.API_ROOT_URL = '#{root_url}';

如上所述,root_url设置为/。

然而,分析Vue代码更紧密的乐趣:

代码语言:javascript
复制
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。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2017-12-31 14:05:16

我不确定您的应用程序是如何工作的,以及在哪里传递数据的机制,但我怀疑您可能需要将querystring参数中的use_ssl=true传递到您的/validate端点。

目前,use_ssl=false正在被传递,这很可能是返回一个非SSL响应。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48001934

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档