Rails 3.1 SSL 重定向循环

发布于 2024-12-29 02:20:14 字数 3317 浏览 1 评论 0 原文

像往常一样,我在将 Rails 应用程序部署到不同的临时环境时遇到了奇怪的问题。我已将 Rails 3.1 应用程序配置为使用 SSL config.force_ssl = true。当我对项目进行 warble 时,war 会正确部署到我们的测试 JBoss 服务器 (4.2.2),并且可以通过 https 进行访问。当我转向生产时,该应用程序无法访问,并显示以下消息。

更新 好的,再次部署后我有了更多信息。该网站目前托管在 https://ibs.collegegreen.net/Campus-Commerce 上,当页面被点击,我收到一个重定向循环错误,最终解析为 https://ibs.collegegreen.net/Campus-Commerce///////////////////////

此外,我们还有一个 Apache 服务器,它将请求代理回我们的 JBoss 服务器。

[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp//] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp///] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp/////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp//////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp///////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp////////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp/////////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp//////////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp///////////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp////////////] miss

生产.rb

MyApp::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = true

  # Generate digests for assets URLs
  config.assets.digest = true

  config.assets.js_compressor = :closure

  # Defaults to Rails.root.join("public/assets")
  #config.assets.manifest = Rails.root.join("config")

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  config.force_ssl = true

  #config.assets.precompile += [ '*.js', 'cc/*.js', '*.css', 'skins/*.css', 'smoothness/*.css' ]
  config.assets.precompile += %w( *.css *.js )

  # Enable threaded mode
  config.threadsafe!

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

end

As usual, I'm having strange issues with deploying a Rails app to our different staging environments. I have configured my Rails 3.1 app to use SSL config.force_ssl = true. When I warble the project the war deploys correctly to our test JBoss server (4.2.2), and is accessible over https. When I move to production, the app is not accessible giving the following messages.

UPDATE
Ok, after deploying again I have a little more information. The site is currently hosted on https://ibs.collegegreen.net/Campus-Commerce when the page is hit, I receive a redirect loop error that eventually resolves to https://ibs.collegegreen.net/Campus-Commerce//////////////////////

In addition, we have an Apache server that proxies the requests back to our JBoss servers.

[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp//] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp///] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp/////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp//////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp///////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp////////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp/////////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp//////////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp///////////] miss
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] cache: [GET /MyApp////////////] miss

production.rb

MyApp::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = true

  # Generate digests for assets URLs
  config.assets.digest = true

  config.assets.js_compressor = :closure

  # Defaults to Rails.root.join("public/assets")
  #config.assets.manifest = Rails.root.join("config")

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  config.force_ssl = true

  #config.assets.precompile += [ '*.js', 'cc/*.js', '*.css', 'skins/*.css', 'smoothness/*.css' ]
  config.assets.precompile += %w( *.css *.js )

  # Enable threaded mode
  config.threadsafe!

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小忆控 2025-01-05 02:20:14

我们发现了这个问题,问题出在 Apache 上。我们发现以下链接与调整 Apache http://forum.webfaction.com/viewtopic 相关。 php?id=995

We found the issue, it was with Apache. We found the following link relevant to adjusting Apache http://forum.webfaction.com/viewtopic.php?id=995

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文