2016-05-13 9 views
0

ich habe folgendes das SSL-Zertifikat zu erstellen.Ubuntu: HTTPS nicht funktioniert auf Nginx

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

Ich habe auch die folgenden nginx config. Die http funktioniert auf Port 8002. Das https funktioniert jedoch überhaupt nicht. Das Nginx-Conf und das SSL-Zertifikat befinden sich im selben Ordner.

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 
    } 

Antwort

1

Zunächst einmal, was in nginx Fehlerprotokoll ??? Das Protokoll muss zuerst überprüft werden und sollte an die Frage angehängt werden.

Wie ich sehe, haben Sie cerf.key und cerf.crt Dateien erstellt, während cert.key & cert.crt konfiguriert - das nginx nicht Folge führen sollte zu starten. Bitte zeigen Sie uns sudo nginx -t Ausgabe.