Nginx+uwsgi+Django的HTTPS问题

eightbrother 2011-10-17

搭建了一台nginx+uwsgi+django1.3的服务器。由于设计需要必须走HTTPS,但是按照默认配置后访问却总是出现问题。查阅了uwsgi文档后解决了。

server {
        listen   80;
        server_name 127.0.0.1;

        ssl                  on;
        ssl_certificate      server.crt;
        ssl_certificate_key  server.key;
        ssl_session_timeout  5m;
        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;

        access_log logs/access_log;
        uwsgi_connect_timeout 300;
        location / {
                uwsgi_param UWSGI_SCHEME https;
                uwsgi_pass 127.0.0.1:9000;
                include        uwsgi_params;
        }
        location /static {
                alias /var/www/html/static;
                access_log off;
        }
        location /tmp {
                alias /tmp;
                access_log off;
        }
    }

问题的关键是这行:

uwsgi_param UWSGI_SCHEME https;

REF:http://projects.unbit.it/uwsgi/wiki/uWSGIVars

相关推荐