title: Nginx Load balancer support HTTP and HTTPS
body: <p>I have configured a Nginx load balancer so it can split traffic with more Nginx+PHP5-FPM servers. The load balancer Nginx website.com.conf (vhost) is configured as this:</p>
  
  <pre><code>upstream backend  {
      ip_hash;
      server IP_NGINX_PHP5FPM_NODE1;
      server IP_NGINX_PHP5FPM_NODE2;
  }
  
  server {
      listen       80;
      server_name  www.website.com website.com;
  
      location / {
          proxy_set_header HOST $host;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass  http://backend;
      }
  }
  </code></pre>
  
  <p>So when an user visits the site via HTTP the load balancer can use two nodes to handle the traffic. All works fine with HTTP but I need it to support also HTTPS. So I edited it as this:</p>
  
  <pre><code>upstream backend  {
      ip_hash;
      server IP_NGINX_PHP5FPM_NODE1;
      server IP_NGINX_PHP5FPM_NODE2;
  }
  
  server {
      listen       80;
      listen       443 ssl;
      server_name  www.website.com website.com;
  
      ssl on;
      ssl_certificate /var/www/website.com/ssl/website-bundle.crt;
      ssl_certificate_key /var/www/website.com/ssl/diosesbueno.key;
      ssl_buffer_size 8k;
      ssl_stapling on;
      ssl_stapling_verify on;
      ssl_trusted_certificate /var/www/website.com/ssl/trustchain.crt;
      ssl_dhparam /var/www/website.com/ssl/dhparam.pem;
      ssl_session_cache shared:SSL:20m;
      ssl_session_timeout 10m;
      ssl_prefer_server_ciphers on;
      ssl_ciphers HIGH:!aNULL:!MD5:!kEDH;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  
      location / {
          proxy_set_header HOST $host;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass  http://backend;
      }
  }
  </code></pre>
  
  <p>It works if I visit the site via HTTPS but Firefox says the website contains unencrypted elements and gives an alert, see this screenshot: <a href="http://postimg.org/image/m15g9zgzh/" rel="nofollow">http://postimg.org/image/m15g9zgzh/</a></p>
  
  <p>Can someone help me fix this issue ?</p>