# SSL for login pages - how do I configure this? (dreamhost)

**URL:** <https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005>\
**Category:** Rails\
**Created:** [September 8, 2006, 12:59pm UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005 "2006-09-08T12:59:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 8, 2006, 12:59pm UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005/1 "2006-09-08T12:59:43Z")

</div>

Hi,

Can anyone give me a headsup/pointer re how to enable some (or all?) of  
my pages to be SSL encrypted (e.g. login pages where password is being  
transfered)? Is this in the ruby application or part of the apache  
configuration? What doco should I brush up on?

I’m on Dreamhost so I don’t think I have full access to apache.

Tks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 9, 2006, 12:44pm UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005/2 "2006-09-09T12:44:12Z")

</div>

bump (still interested re this item if anyone knows how to do this)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 13, 2006, 10:56pm UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005/3 "2006-09-13T22:56:29Z")

</div>

bump (still interested re this item if anyone knows how to do this)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 14, 2006, 1:12am UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005/4 "2006-09-14T01:12:47Z")

</div>

On Thu, Sep 14, 2006 at 06:50:54AM +1000, Greg H. wrote:

> > > Can anyone give me a headsup/pointer re how to enable some (or all?) of  
> > > my pages to be SSL encrypted (e.g. login pages where password is being  
> > > transfered)? Is this in the ruby application or part of the apache  
> > > configuration? What doco should I brush up on?
> > > 
> > > I’m on Dreamhost so I don’t think I have full access to apache.

Well, I don’t know how you would deal with it there, so my instructions  
will be general.

Making some of your pages ssl requires some setup on your web server in  
addition to some setup in your application.

On the web server, just make an ssl site.

You can then set up  
some methods in app/controllers/application.rb which you can then use as  
a  
before\_filter in your controllers. The two methods you need are  
“ssl\_required” and “ssl\_prohibited”. They look something like this:

def ssl\_required  
unless @request.ssl?  
redirect\_to “https://#{@request.host}/#{@request.request\_uri}”  
end  
end

def ssl\_prohibited  
if @request.ssl?  
redirect\_to “http://#{@request.host}/#{@request.request\_uri}”  
end  
end

(this is untested, you might need to fix it. If so, please followup  
this post with the fix for future searching)

You can then put:

before\_filter :ssl\_required, :only =\> [:cart, :checkout]

to force some items to ssl. You then use the opposite:

before\_filter: ssl\_prohibited

for controllers or actions that shouldn’t be ssl.

If you have access to web server config, you can also force ssl or  
non-ssl on certain paths using “redirectmatch”. Doing it in your app  
gives you a little more flexibility and keeps it all in one place.

## Michael

Michael Darrin Chaney  
removed\_email\_address@domain.invalid  
[http://www.michaelchaney.com/](http://www.michaelchaney.com/)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 14, 2006, 9:34am UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005/5 "2006-09-14T09:34:20Z")

</div>

excellent - thanks for these pointers Michael

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 21, 2006, 11:42pm UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005/6 "2006-10-21T23:42:43Z")

</div>

it sounds like at dreamhost I have to pay more $$ to get SSL for my app  
per  
this  
link[http://wiki.dreamhost.com/index.php/KB\_/\_Account\_Control\_Panel\_/\_Goodies\_::\_Secure\_Server](http://wiki.dreamhost.com/index.php/KB_/_Account_Control_Panel_/_Goodies_::_Secure_Server).

That is extra for:  
(a) purchase a unique ip add-on ($3.95/month)  
(b) purchase a secure certificate on their own from a party

Does this sound normal/reasonable? Is there another way to get SSL  
happening for my application on dreamhost?

Tks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 22, 2006, 12:00am UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005/7 "2006-10-22T00:00:50Z")

</div>

On Oct 21, 2006, at 4:37 PM, Greg H. wrote:

> it sounds like at dreamhost I have to pay more $$ to get SSL for my  
> app per this link.
> 
> That is extra for:  
> (a) purchase a unique ip add-on ($3.95/month)  
> (b) purchase a secure certificate on their own from a party
> 
> Does this sound normal/reasonable? Is there another way to get SSL  
> happening for my application on dreamhost?

Sounds very reasonable for a shared host. You will always need a  
certificate (Go Daddy has them for very cheap) and a static IP  
address for SSL. Even if you were on a dedicated server, you’d have  
to allocate a unique IP address and buy a certificate.

Brad

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 22, 2006, 12:06am UTC](https://www.ruby-forum.com/t/ssl-for-login-pages-how-do-i-configure-this-dreamhost/68005/8 "2006-10-22T00:06:50Z")

</div>

ok - thanks Brad
