Ubuntu:HTTPS不支持Nginx

时间:2016-05-13 19:13:28

标签: ubuntu ssl nginx https webserver

我已使用以下内容创建SSL证书。

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/cerf.key -out /etc/nginx/ssl/cerf.pem

我还有以下nginx配置。 http在端口8002上工作正常。但是,https根本不工作。 nginx conf和SSL证书位于同一文件夹中。

upstream django {
    server unix:////var/www/dj_test_prj/dj_test_prj/site.bot.sock; # for a file socket
    #server 127.0.0.1:8000; # for a web port socket (we will use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8002;
    # the domain name it will serve for
    server_name .example.com; # substitute your machine IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    location /media  {
        alias  /var/www/dj_test_prj/media;  # your Django project  media files - amend as required
    }

    location /static {
        alias  /var/www/dj_test_prj/static; # your Django project  static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /var/www/dj_test_prj/dj_test_prj/uwsgi_params.bot; # the uwsgi_params file you installed
    }
}


server {
    listen 443;
    server_name .example.com; # substitute your machine IP address or FQDN
    charset     utf-8;

    ssl on;
    ssl_certificate cert.pem;
    ssl_certificate_key cert.key;

    ssl_session_timeout 5m;

    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
    ssl_prefer_server_ciphers on;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    location /media  {
        alias  /var/www/dj_test_prj/media;  # your Django project  media files - amend as required
    }

    location /static {
        alias  /var/www/dj_test_prj/static; # your Django project  static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /var/www/dj_test_prj/dj_test_prj/uwsgi_params.bot; # the uwsgi_params file you installed
    }

1 个答案:

答案 0 :(得分:1)

首先,写入nginx错误日志的是什么? 必须首先检查日志,并将其附加到问题上。

我可以看到,您已配置cerf.key& cerf.crt - 这会导致nginx启动失败。请告诉我们cert.key输出。