Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6591281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:24:17+00:00 2026-05-25T17:24:17+00:00

I’m moving an app to heroku and am having some issues with ssl and

  • 0

I’m moving an app to heroku and am having some issues with ssl and redirects.

I’m on rails 3.1 and I’ve tried forcing ssl with middleware in the environments production.rb. I’ve all tried adding it to the application controller.

The problem is, when I do a full site force of ssl, I’m unable to redirect to www before it hits the SSL requirement. This is important because a user would be shown a bad SSL cert warning if they access https://mydomain.com. If they proceed, they then get redirect to ‘www’.

SSL forcing is working, redirecting to ‘www’ subdomain is working, I just need to do the redirect first.

Any ideas?

Per Nathan’s Comment:

I had an imperfect solution. My root_path is not forcing ssl. All parts with sensitive info are forcing it. Upon arriving, all traffic is directed to www with this in my routes.rb:

constraints(:host => "domain.com") do
  match "(*x)" => redirect { |params, request|
    URI.parse(request.url).tap { |x| x.host = "www.domain.com" }.to_s
  }
  end 

This could hide most of the issues, as by the time to user clicked on sign in or anything else, they were now at the www domain. The browser will not giving a warning about certificates. This worked fine for this certain project. Another project I ended up paying the big bucks for a signed wild card cert.

Sorry, not a real solution. If you go to https://domain.com/forcedsslpath the project still gives the security warnings.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:24:17+00:00Added an answer on May 25, 2026 at 5:24 pm

    Since your 301 is being sent by the application, and the request can’t even reach the application before hitting the middleware (on which rack-ssl runs), your only solutions are to change the middleware or to do the redirect before it even hits the middleware.

    For the latter, you’d have to poke around Heroku. I don’t use it myself. On a VPS deployment, you’d just add the redirect on your forward-facing web server (Apache, nginx) before it even hit the middleware. This seems like a common case, so I imagine Heroku might have something there for you.

    For the former, it shouldn’t be hard. The rack-ssl middleware is very, very simple, and it shouldn’t be hard to monkeypatch it to suit your needs.

    https://github.com/josh/rack-ssl/blob/master/lib/rack/ssl.rb#L58

    I imagine that something like url.host = "www.myhost.com" might be what you’d want (although you can probably tell there are probably more FQDN-agnostic ways to do it).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am using Paperclip to handle profile photo uploads in my app. They upload
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.