# Request.ssl? not working

**URL:** <https://www.ruby-forum.com/t/request-ssl-not-working/113605>\
**Category:** Rails\
**Created:** [September 2, 2007, 7:13pm UTC](https://www.ruby-forum.com/t/request-ssl-not-working/113605 "2007-09-02T19:13:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 2, 2007, 7:13pm UTC](https://www.ruby-forum.com/t/request-ssl-not-working/113605/1 "2007-09-02T19:13:05Z")

</div>

My rails app can not tell if it is on an SSL connection or not. I am  
using https:// as my protocol and then we I inspect request.ssl? it  
returns false. Any ideas why it would be doing this?

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 2, 2007, 9:51pm UTC](https://www.ruby-forum.com/t/request-ssl-not-working/113605/2 "2007-09-02T21:51:58Z")

</div>

You need to check that your webserver is making use of a specific  
environment variable that the request.ssl? makes use of

Ben J. wrote:

> My rails app can not tell if it is on an SSL connection or not. I am  
> using https:// as my protocol and then we I inspect request.ssl? it  
> returns false. Any ideas why it would be doing this?

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 2, 2007, 10:16pm UTC](https://www.ruby-forum.com/t/request-ssl-not-working/113605/3 "2007-09-02T22:16:56Z")

</div>

Scott A s wrote:

> You need to check that your webserver is making use of a specific  
> environment variable that the request.ssl? makes use of
> 
> Ben J. wrote:
> 
> > My rails app can not tell if it is on an SSL connection or not. I am  
> > using https:// as my protocol and then we I inspect request.ssl? it  
> > returns false. Any ideas why it would be doing this?

I’m u sing the latest apache with the mod\_proxy\_balancer and then  
mongrel. So nothing out of the ordinary. Do I need to turn on some  
options or something?

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 2, 2007, 10:43pm UTC](https://www.ruby-forum.com/t/request-ssl-not-working/113605/4 "2007-09-02T22:43:40Z")

</div>

the problem is that the SSL request arrives to the apache server, and  
not to  
the mongrel server …  
the connection between apache and mongrel is not a SSL request …

On Sunday 02 September 2007 17:16:56 Ben J. wrote:

> mongrel. So nothing out of the ordinary. Do I need to turn on some  
> options or something?

–  
Rodrigo Urubatan Ferreira Jardim  
removed\_email\_address@domain.invalid  
[http://www.urubatan.com.br](http://www.urubatan.com.br)

> **[Marketing Digital | Agência SociALL](https://www.techoffice.com.br/)**
>
> Agênia SociALL Seu negócio nas redes sociais com custos na medida do seu bolso

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 2, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/request-ssl-not-working/113605/5 "2007-09-02T22:55:27Z")

</div>

Rodrigo Urubatan Ferreira Jardim wrote:

> the problem is that the SSL request arrives to the apache server, and  
> not to  
> the mongrel server …  
> the connection between apache and mongrel is not a SSL request …
> 
> On Sunday 02 September 2007 17:16:56 Ben J. wrote:
> 
> > mongrel. So nothing out of the ordinary. Do I need to turn on some  
> > options or something?
> 
> –  
> Rodrigo Urubatan Ferreira Jardim  
> removed\_email\_address@domain.invalid  
> [http://www.urubatan.com.br](http://www.urubatan.com.br)  
> [http://www.techoffice.com.br](http://www.techoffice.com.br)

I think I found a solution. In my virtual host for my ssl connection I  
put:

RequestHeader set X\_FORWARDED\_PROTO ‘https’

This way the ssl? method works fine in rails. Kind of feels like a hack,  
but not really.
