混合内容错误nginx在kubernetes中用于铁轨应用程序



使用Nginx Ingress Load Balancer实现了在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:5000&external_hostname=& external_hostname =&amp.amp;5D =主机名'。 该请求已被阻止;内容必须通过https提供。

nginx配置:https://github.com/kubic-project/caasp-services/blob/master/master/contrib/helm-charts/portus/portus/templates/nginx-configmap.yaml

环境:

  • GCP中的Kubernetes
  • 通过掌舵部署的所有资源
  • SSL由Kube-Lego提供
  • 带葡萄API宝石的铁路应用
  • 葡萄安装API如下: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 =&am -x选项-h'访问 - control-request-method:get'-h'rount:https://staging.foo.bar'-h'access-control-request-headers: X-CSRF-TOKEN' - 压缩

,看起来根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';

参数设置为在查询中使用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

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

当前正在通过use_ssl=false,这可能正在返回非SSL响应。

最新更新