title: Laravel Apache to Nginx HTTPS redirect
body: <p>I'm migrating a Laravel 4.2 site from Apache to Nginx, and having problems with changing the asset URLs over to HTTPS.</p>
  
  <p>Here's an example of how I'm linking to css files in my blade:</p>
  
  <pre><code>{{ HTML::style('css/core.css') }}
  </code></pre>
  
  <p>In my old Apache setup, this rendered as HTTPS in the output:</p>
  
  <pre><code>&lt;link href="https://my.site.com/css/core.css" rel="stylesheet" type="text/css" media="all"&gt;
  </code></pre>
  
  <p>In my new nginx setup, however, the page redirects to HTTPS, but all of the internal links (forms, CSS, JS etc) all show as HTTP which causes a load of "mixed content" errors.</p>
  
  <pre><code>&lt;link href="http://my.site.com/css/core.css" rel="stylesheet" type="text/css" media="all"&gt;
  </code></pre>
  
  <p>Here's my nginx.conf:</p>
  
  <pre><code>server {
          listen 80;
          server_name my.site.com;
          return 301 https://$server_name$request_uri;
  }
  
  server {
          listen 443 ssl;
          ssl on;
          ssl_certificate /etc/ssl/my.site.com.chained.crt;
          ssl_certificate_key /etc/ssl/my.site.com.key;
          ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
          ssl_prefer_server_ciphers on;
          ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4";
  
          server_name my.site.com;
          root /var/www/public;
          index index.php index.html index.htm;
          access_log /var/log/access.log;
          error_log /var/log/_error.log;
  
          try_files $uri $uri/ @rewrite;
          location @rewrite {
                  rewrite ^/(.*)$ /index.php?_url=/$1;
          }
          location ~ \.php {
                  fastcgi_pass 127.0.0.1:9000;
                  fastcgi_index /index.php;
                  include /etc/nginx/fastcgi_params;
                  fastcgi_split_path_info ^(.+\.php)(/.+)$;
                  fastcgi_param PATH_INFO $fastcgi_path_info;
                  fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
                  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          }
  
          location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
                  root /var/www/public;
          }
  
          location ~ /\.ht {
                  deny all;
          }
  }
  </code></pre>
  
  <p>I think I can force Laravel to generate secure URLs setting the $secure attribute on HTML::style method, but it's gonna be a big job to change the whole app for that.</p>
  
  <p>How does Laravel apparently "know" to render HTTPS links in Apache, but not nginx, and is there a simple way to force it globally? </p>