title: Make rails url_helpers use https in production
body: <p>I use Rails <em>url_helpers</em> to build resources urls in my app. 
  An example of a url in development is <code>http://localhost:3000/resource/1</code>, generated by the <code>resource_url(resource)</code> <em>url_helper</em>.</p>
  
  <p>I use nginx in production to <em>proxy_pass</em> the requests to my rails app. My nginx listens on port 433 https and redirects to my rails app on port 5000 http:</p>
  
  <pre><code>server {
    listen 443 ssl;
    server_name     api.staging.zup.me;
  
    ssl_certificate /etc/ssl/certs/cert.crt;
    ssl_certificate_key /etc/ssl/certs/cert.key;
  
    location / {
      proxy_redirect off;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $host:$server_port;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass      http://localhost:5000;
    }
  }
  </code></pre>
  
  <p>Because the request that my Rails app receives from the nginx proxy is <strong>http</strong>, it is generating the urls like, <code>http://example.com/resource/1</code>, but only in production I want all my urls to use <strong>https</strong>, for example, <code>https://example.com/resource/1</code>.</p>
  
  <p>What is the best way to make Rails generate urls with the <strong>https</strong> protocol only in production?</p>