# Strange ssl\_requirement plugin issues

**URL:** <https://www.ruby-forum.com/t/strange-ssl-requirement-plugin-issues/121440>\
**Category:** Rails\
**Created:** [November 28, 2007, 12:06am UTC](https://www.ruby-forum.com/t/strange-ssl-requirement-plugin-issues/121440 "2007-11-28T00:06:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@kyle](https://www.ruby-forum.com/u/kyle)\
**Post date:** [November 28, 2007, 12:06am UTC](https://www.ruby-forum.com/t/strange-ssl-requirement-plugin-issues/121440/1 "2007-11-28T00:06:57Z")

</div>

I’m having problems with the ssl\_requirement plugin. I’m moving my  
app from one server to another. Both servers have the same versions  
of ruby and rails, and the code and ssl certificates on the two  
servers is identical. When a user hits the “checkout” button, he/she  
issues a POST request for the checkout\_1 action. When things are  
working, the server then uses GET to render the template (at least,  
that’s what it looks like it’s doing). This is where the issue  
happens.

The working server renders the template/layout. The misbehaving  
server redirects to the same page over and over until it gives up.  
The good version looks like this:

Rendering within layouts/store  
Rendering store/checkout\_1  
Completed in 0.29177 (3 reqs/sec) | Rendering: 0.26901 (92%) | DB:  
0.02111 (7%) | 200 OK [[https://74.86.134.210/store/checkout\_1](https://74.86.134.210/store/checkout_1)]

The malfunctioning server looks like this:

Redirected to [https://74.86.228.171/store/checkout\_1](https://74.86.228.171/store/checkout_1)  
Filter chain halted as  
[#\<ActionController::Filters::ClassMethods::SymbolFilter:0xb770a58c  
@filter=:ensure\_proper\_protocol\>] returned false.  
Completed in 0.00024 (4236 reqs/sec) | DB: 0.00000 (0%) | 302 Found  
[[http://74.86.228.171/store/checkout\_1](http://74.86.228.171/store/checkout_1)]  
(repeat ad nauseum)

If I go directly to the https:// address, I get the same problem.  
However, if I’m at the home page and add an ‘s’ to the ‘http’, it  
encrypts. On the working version, it redirects to a non-encrypted  
‘http’ home page.

So, it looks like the ssl\_requirement plugin is acting up. For the  
checkout\_1 action, I have an :ssl\_required declaration in the  
controller. I also have the ‘include SslRequirement’ in my  
application controller. But, like I said, the code is identical for  
the two apps. That’s what I can’t figure out.

Does this infinite loop look familiar or dangerously suspicious to  
anybody? I’d appreciate any help or suggestions, and I’ll supply any  
more information that could be helpful. The hosting tech support has  
looked at the problem and is as stumped as I am. They said that the  
Apache configs were the same, too, for what it’s worth.

Thank you!

-Kyle

---

<div class="post-metadata">

**Author:** ![kyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@kyle](https://www.ruby-forum.com/u/kyle)\
**Post date:** [November 28, 2007, 10:23am UTC](https://www.ruby-forum.com/t/strange-ssl-requirement-plugin-issues/121440/2 "2007-11-28T10:23:58Z")

</div>

On Nov 27, 2007 11:06 PM, Kyle [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> server redirects to the same page over and over until it gives up.  
> Are the two setups using the same web servers/proxies? I ran into a  
> similar  
> problem a while ago because a server wasn’t passing along the necessary  
> headers to indicate whether a request was SSL or not.

James.

–  
James S.  
Web D. and Consultant

> **[Processing Greenbelt 2009](https://jystewart.net/2009/09/08/processing-greenbelt-2009/)**
>
> We did, in fact, make a newspaper. The hour or so after my last post were more than a little stressful, but the results (a few typos and a printing hiccup that most certainly wasn’t our fault…

---

<div class="post-metadata">

**Author:** ![kyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@kyle](https://www.ruby-forum.com/u/kyle)\
**Post date:** [November 28, 2007, 6:21pm UTC](https://www.ruby-forum.com/t/strange-ssl-requirement-plugin-issues/121440/3 "2007-11-28T18:21:59Z")

</div>

The tech assures me that all servers, settings, etc. are the same.

“Please note that both the servers are using the Apache web server  
with same configuration. We have compared the vhost entries also. Also  
we made sure that both are having the same version on the rails and  
ruby.”

I tried re-installing the app by building it on the server and only  
uploading code files. I installed the ssl\_requirement plugin on the  
server as well. Same issue. Bizarre.

-Kyle

---

<div class="post-metadata">

**Author:** ![kyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@kyle](https://www.ruby-forum.com/u/kyle)\
**Post date:** [November 28, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/strange-ssl-requirement-plugin-issues/121440/4 "2007-11-28T21:30:37Z")

</div>

This code snippet from the ssl\_requirement.rb plugin shows me where  
things are breaking down, but now exactly why.

-----CODE-----  
def ensure\_proper\_protocol  
return true if ssl\_allowed?

if ssl\_required? && !request.ssl?  
redirect\_to “https://” + request.host + request.request\_uri  
return false  
elsif request.ssl? && !ssl\_required?  
redirect\_to “http://” + request.host + request.request\_uri  
return false  
end  
end  
-----CODE-----

By looking at the first ‘if’, and based on the symptoms that I’m  
experiencing, it seems that rails isn’t able to interpret my request  
as SSL after redirecting to ‘[https://host/uri](https://host/uri)’. I don’t think that  
the ssl\_required is getting messed up, so it would have to be the  
second part (!request.ssl?). Of course, a request for resources at  
https anything should be considered by rails to be SSL, right? Since  
that isn’t being interpreted correctly, the ensure\_proper\_protocol  
method keeps redirecting to [https://host/uri](https://host/uri) until it dies.

Does this help anybody sniff out a configuration issue somewhere?

Thanks again!

-Kyle

---

<div class="post-metadata">

**Author:** ![kyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@kyle](https://www.ruby-forum.com/u/kyle)\
**Post date:** [November 28, 2007, 10:11pm UTC](https://www.ruby-forum.com/t/strange-ssl-requirement-plugin-issues/121440/5 "2007-11-28T22:11:39Z")

</div>

OK, finally I found this post:

[http://www.hostingrails.com/forums/everything\_else\_thread/420](http://www.hostingrails.com/forums/everything_else_thread/420)

It’s from my hosting company, and I’m using mongrel as they describe.  
The issue seems to be in an Apache Vhost setting. Is there a quick  
fix that would make a request to https:// pass the request.ssl? test?  
I sent tech support the urls of all encrypted pages on my server, but  
I’d much rather just be able to get SslRequirement working so that I  
can add/modify these settings myself.

Thanks!

-Kyle

---

<div class="post-metadata">

**Author:** ![kyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@kyle](https://www.ruby-forum.com/u/kyle)\
**Post date:** [December 6, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/strange-ssl-requirement-plugin-issues/121440/6 "2007-12-06T16:30:36Z")

</div>

Hey ,  
I am facing the same problem. I used the link above  
[http://www.hostingrails.com/forums/everything\_else\_thread/420](http://www.hostingrails.com/forums/everything_else_thread/420)  
but it still does not work. In the apache logs I see that the mongrel  
is in the error start  
and in the mongrel logs i see ensure\_proper\_protocol returned false.  
A similar issue you mentioned above.  
How did u resolve that finally. Any suggestions … i have spent couple  
of days on this…  
Let me know.

Thanks

Dhaval
