# Simple SSL Question

**URL:** <https://www.ruby-forum.com/t/simple-ssl-question/235236>\
**Category:** NGINX\
**Created:** [June 8, 2013, 8:19pm UTC](https://www.ruby-forum.com/t/simple-ssl-question/235236 "2013-06-08T20:19:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [June 8, 2013, 8:19pm UTC](https://www.ruby-forum.com/t/simple-ssl-question/235236/1 "2013-06-08T20:19:16Z")

</div>

Hi,

I’m using nginx with SSL, and I want to always redirect to www,  
regardless of whether the request is http or https. I just want to  
redirect to the respective protocol but with www.

I have the port 80 server block working fine. Beneath my first server  
block I have…

server {  
listen 80;  
server\_name [example.com](http://example.com);  
return 301 http://www.example.com$request\_uri;  
}

and this works fine. But for my port 443 server block for https, I have  
all kinds of information inside regarding ssl on and different ciphers  
to use.

I really don’t want to mess up anything up related to security by doing  
something stupid… so my question is on this second block for port 443  
underneath the first one…

server {  
listen 443;  
server\_name [example.com](http://example.com);  
return 301 https://www.example.com$request\_uri;  
}

do I need anything else? do I need ssl on or any other security related  
things? If they visit non-www does that mean it transfers the request  
insecurely or something (even for a split second while its redirecting?)

Just want to make sure what I have is solid and secure. It seems to work  
but I want to double check.

Thanks!

---

<div class="post-metadata">

**Author:** ![Travis\_Maxwell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/4da419/32.png) [@Travis\_Maxwell](https://www.ruby-forum.com/u/Travis_Maxwell)\
**Post date:** [June 8, 2013, 8:30pm UTC](https://www.ruby-forum.com/t/simple-ssl-question/235236/2 "2013-06-08T20:30:23Z")

</div>

Hello,

On Sat, Jun 8, 2013 at 2:18 PM, Travis Maxwell  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> ```
> listen 80;
> 
> ```
> 
> underneath the first one…  
> ​​
> 
> ​  
> Put both ‘listen’ directives in the same server block.

​

> Just want to make sure what I have is solid and secure. It seems to work  
> but I want to double check.
> 
> Thanks!

* * *

_B. R._

---

<div class="post-metadata">

**Author:** ![Travis\_Maxwell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/4da419/32.png) [@Travis\_Maxwell](https://www.ruby-forum.com/u/Travis_Maxwell)\
**Post date:** [June 8, 2013, 8:55pm UTC](https://www.ruby-forum.com/t/simple-ssl-question/235236/3 "2013-06-08T20:55:31Z")

</div>

You need to include the SSL certificate and the key directives on the  
server block that does the SSL redirect.  
Le 8 juin 2013 20:30, “B.R.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) a crit :
