title: Redirect HTTP to HTTPS from Nginx is not working
body: <p>Type: <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a> => <strong>ssl ok</strong>
  But type: www.example.com and example.com is http <strong>no redirect</strong> https. (www redirect to non-www).</p>
  
  <p>WordPress Address (URL) and Site Address (URL): https//example.com</p>
  
  <p>/etc/nginx/conf.d/example.com.conf</p>
  
  <pre><code>server {
  listen 80; 
  server_name example.com www.example.com;
  return 301 https://$server_name$request_uri;
  }
  server {
  listen 443 ssl;
  server_name example.com www.example.com;
  ssl on;
  ssl_certificate /etc/nginx/ssl/cert_chain.crt;
  #ssl_CACertificate_File /etc/nginx/ssl/example.com.ca-bundle;
  ssl_certificate_key /etc/nginx/ssl/example.com.key; 
  access_log off;
  # access_log /home/example.com/logs/access_log;
  error_log off;
  # error_log /home/example.com/logs/error.log; 
  add_header X-Frame-Options SAMEORIGIN;
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";
  root /home/example.com/public_html;
  include /etc/nginx/conf/ddos2.conf;
  index index.php index.html index.htm;
  server_name example.com;
  </code></pre>
  
  <p>How to fix it ?
  Sorry my bad English, thank you.</p>