<div dir="ltr">Hi,<br><br>I&#39;m running a website with nginx as a proxy and for static files.<br>I&#39;m using the ubuntu lucid nginx package - version 0.7.65<br><a href="http://example.com">http://example.com</a> redirect to <a href="http://www.example.com">http://www.example.com</a> - works<br>
<a href="https://www.example.com">https://www.example.com</a> - SSL works<br><a href="https://example.com">https://example.com</a> redirect to <a href="https://www.example.com">https://www.example.com</a> - doesn&#39;t work and show untrusted connection in the browser.<br>
<br>I have two questions:<br>- Why SSL only works when I use default on the listen: &quot;listen     443 default;&quot;<br>- Why I can&#39;t redirect https:// to <a href="https://www">https://www</a> before I&#39;m getting the untrusted connection warning.<br>
<br>Thanks<br><br>My config file:<br>server {<br>    listen   80;<br>    server_name  <a href="http://example.com.com">example.com.com</a>;<br>    rewrite ^/(.*) <a href="http://www.example.com/$1">http://www.example.com/$1</a> permanent;<br>
}<br><br>server {<br>    listen       80;<br>    server_name  <a href="http://www.example.com">www.example.com</a>;<br><br>    location / {<br>        proxy_pass <a href="http://127.0.0.1:8000">http://127.0.0.1:8000</a>;<br>
    }<br><br>    ...<br>}<br><br>server {<br>    listen   443;<br>    server_name  <a href="http://example.com.com">example.com.com</a>;<br>    rewrite ^/(.*) <a href="https://www.example.com.com/$1">https://www.example.com.com/$1</a> permanent;<br>
}<br><br>server {<br>    listen     443 default;<br><br>    ssl    on;<br>    ssl_certificate    /etc/nginx/ssl/example.pem;<br>    ssl_certificate_key    /etc/nginx/ssl/example.key;<br><br>    server_name  <a href="http://www.example.com">www.example.com</a>;<br>
<br>    location / {<br>        proxy_pass <a href="http://127.0.0.1:8000">http://127.0.0.1:8000</a>;<br>    }<br>    ...<br>}<br><br></div>