<p dir="ltr">You need to include the SSL certificate and the key directives on the server block that does the SSL redirect.</p>
<div class="gmail_quote">Le 8 juin 2013 20:30, "B.R." <<a href="mailto:reallfqq-nginx@yahoo.fr">reallfqq-nginx@yahoo.fr</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Hello,<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 8, 2013 at 2:18 PM, Travis Maxwell <span dir="ltr"><<a href="mailto:the.energetic@gmail.com" target="_blank">the.energetic@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
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.<br>
<br>
I have the port 80 server block working fine. Beneath my first server block I have...<br>
<br>
server {<br>
    listen      80;<br>
    server_name <a href="http://example.com" target="_blank">example.com</a>;<br>
    return 301  <a href="http://www.example.com" target="_blank">http://www.example.com</a>$request_uri;<br>
}<br>
<br>
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.<br>
<br>
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...<br>
<br>
server {<br>
    listen      443;<br>
    server_name <a href="http://example.com" target="_blank">example.com</a>;<br>
    return 301  <a href="https://www.example.com" target="_blank">https://www.example.com</a>$request_uri;<br>
}<br>
<br>
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?)<br>
<div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline"></div><br></blockquote><div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">


Put both 'listen' directives in the same server block.<br></div><br></div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Just want to make sure what I have is solid and secure. It seems to work but I want to double check.<br>
<br>
Thanks!<br></blockquote></div><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font>
</div></div>
<br>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div>