title: Setting up Https in Django 1.7+ with uwsgi and Nginx
body: <p>I'm having trouble setting up my site with https. At the moment, I have my nginx server set to listen to both http and https responses. </p>
  
  <p>However, now I only want to allow https and redirect any http requests to htpps.</p>
  
  <p>I tried this post without any luck: <a href="https://stackoverflow.com/questions/8153875/how-to-deploy-an-https-only-site-with-django-nginx">How to deploy an HTTPS-only site, with Django/nginx?</a></p>
  
  <p>What is the recommended way of doing this in Django 1.7+?</p>
  
  <p>Below is my ngninx.conf file:</p>
  
  <pre><code># mysite_nginx.conf
  
  # the upstream component nginx needs to connect to
  upstream django {
      server unix:///uwsgi-tutorial/mysite/mysite.sock; # for a file socket
  #   server 127.0.0.1:8001; # for a web port socket (we'll use this first)
  }
  
  # configuration of the server
  server {
      # the port your site will be served on
      listen 80;
      listen 443 default_server ssl;
      #ssl on;
      ssl_certificate     /uwsgi-tutorial/conf/www.example.com.chained.crt;
      ssl_certificate_key /uwsgi-tutorial/conf/www.example.com.key;
  
      # the domain name it will serve for
  #   server_name localhost; # substitute your machine's IP address or FQDN
      server_name example.com; # substitute your machine's IP address or FQDN
      charset     utf-8;
  
      # max upload size
      client_max_body_size 75M;   # adjust to taste
  
      # Django media
      location /media  {
          alias /uwsgi-tutorial/mysite/media;  # your Django project's media files - amend as required
      }
  
      location /static {
          alias /uwsgi-tutorial/mysite/static; # your Django project's static files - amend as required
      }
  
      # Finally, send all non-media requests to the Django server.
      location / {
          uwsgi_pass  django;
          include     /uwsgi-tutorial/mysite/uwsgi_params; # the uwsgi_params file you installed
      }
  }
  </code></pre>