Ruby on rails kubernetes for rails应用程序中的混合内容错误nginx入口

Ruby on rails kubernetes for rails应用程序中的混合内容错误nginx入口,ruby-on-rails,nginx,gcp,grape-api,portus,Ruby On Rails,Nginx,Gcp,Grape Api,Portus,在GCP中部署,并实现Nginx入口负载平衡器。Portus加载得很好,但在尝试使用应用程序并填写某些表单时,出现以下错误: VM798:1混合内容:位于 “”已通过HTTPS加载, 但请求了一个不安全的XMLHttpRequest端点 ''. 此请求已被阻止;内容必须通过HTTPS提供 Nginx配置: 环境: GCP中的Kubernetes 通过HERM部署的所有资源 ssl由kube lego提供 Rails应用程序与GrapeAPI gem Grape按如下方式装载api:mount

在GCP中部署,并实现Nginx入口负载平衡器。Portus加载得很好,但在尝试使用应用程序并填写某些表单时,出现以下错误:

VM798:1混合内容:位于 “”已通过HTTPS加载, 但请求了一个不安全的XMLHttpRequest端点 ''. 此请求已被阻止;内容必须通过HTTPS提供

Nginx配置:

环境:

  • GCP中的Kubernetes
  • 通过HERM部署的所有资源
  • ssl由kube lego提供
  • Rails应用程序与GrapeAPI gem
  • Grape按如下方式装载api:
    mount api::RootAPI=>“/”
因此,我确保检查了手动http调用的代码,但没有看到任何内容。我花了一天的时间试图翻阅rails文档和nginx文档,看看是什么导致一些应用程序使用ssl正确加载,而API没有遵循相同的规则

-----更新1------ 经过进一步调查,它似乎与Vue验证程序有关。检查开发人员工具后发现以下情况:

卷曲 '' -X选项-H'访问控制请求方法:获取'-H'来源:'-H'访问控制请求标头: x-csrf-token'--压缩

这里似乎正在调用根url:

javascript:
      window.API_ROOT_URL = '#{root_url}';
根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\u ssl=false
,这很可能返回非ssl响应。

use\u ssl正在参数中调用,它似乎仍然不想工作