title: How to use CloudFlare "Flexible SSL" with Nginx PageSpeed filters
body: <p>I just started using CloudFlare "Flexible SSL", this allows the user to have SSL when connecting to my server (via CloudFlare of course).</p>
  
  <p>Here's how the request goes:</p>
  
  <p><strong>Visitor</strong> &lt;-- SSL --> <strong>CloudFlare</strong>  &lt;-- non-SSL --> <strong>My Server (Nginx w/pagespeed)</strong></p>
  
  <p>The problem comes when Nginx rewrites my resources (css, js, jpegs, etc), nginx always receives an http request from CloudFlare, so obviously Nginx returns the resources as http (in the html) and when the user tries to load them they get an ugly icon on their browsers alerting of insecure content, or not loading at all insecure content breaking the page completely.</p>
  
  <p>These are the filters I'm currently using: <code>pagespeed EnableFilters move_css_above_scripts,move_css_to_head,rewrite_style_attributes,combine_javascript,insert_image_dimensions,collapse_whitespace,sprite_images,ins‌​ert_dns_prefetch;</code></p>
  
  <p>So how can I make nginx pagespeed to return the resources as https? and how as non-https when the request is http?</p>
  
  <p>Thanks.</p>