重定向到https django后出现502错误的网关

时间:2019-02-03 13:43:27

标签: django ubuntu ssl nginx digital-ocean

我一直在尝试使用https加密我的网站,但是在重定向时出现502错误的门禁,我在Ubuntu 14和django上将Digital Ocean与nginx结合使用: 这是我的服务器配置:

upstream app_server {
     server unix:/home/django/gunicorn.socket fail_timeout=0;
 }

server {
   # listen 80 default_server;
   # listen [::]:80 default_server ipv6only=on;
    listen 443 ssl;
    server_name =  programmationetia.com;
    ssl_certificate /etc/letsencrypt/live/programmationetia.com/fullchain.pem ;
    ssl_certificate_key /etc/letsencrypt/live/programmationetia.com/privkey.pem;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
       alias /home/django/django_project/django_project/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/django_project/django_project/static;
    }

    # Proxy the static assests for the Django Admin panel
    location /static/admin {
       alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
    }

    location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_redirect off;
            proxy_buffering off;

            proxy_pass https://app_server;
    }

}

server {
        listen 80;
        server_name programmationetia.com;
        return 301 https://$server_name$request_uri;

}

我遵循了有关使用SSL加密的Sentex教程。 谢谢你的帮助

0 个答案:

没有答案