ignore_invalid_headers   on;

server {
    listen 443 ssl default;
    ssl on;
    ssl_certificate /etc/ssl/certs/circle.pem;
    ssl_certificate_key /etc/ssl/certs/circle.pem;

{% if pillar['deployment_type'] == "production" %}
    location /media  {
        alias /home/{{ pillar['user'] }}/circle/circle/media; # your Django project's media files
    }
    location /static {
        alias /home/{{ pillar['user'] }}/circle/circle/static_collected; # your Django project's static files
    }
{% endif %}
    location /doc {
        alias /home/cloud/circle-website/_build/html;
    }

    location / {
{% if pillar['deployment_type'] == "production" %}
        uwsgi_pass  unix:///tmp/uwsgi.sock;
        include     /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
{% else %}
        proxy_pass        http://localhost:8080;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  Host $http_Host;
        proxy_set_header  X-Forwarded-Protocol https;
{% endif %}
    }

    location /vnc/ {
        proxy_pass http://localhost:9999;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # WebSocket support (nginx 1.4)
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}


server {
  listen 80 default;
  rewrite ^ https://$host/;  # permanent;
}

