0

I am trying to add ssl to my test django server that is on AWS. I followed a tutorial to add ssl with certbot, add the proxy_pass but I never got it to work, so after three days trying all kinds of things, I give up. Could you guys please have a look and let me know where I am wrong? I am also confused about the environment variables, $host is blank and so are the others, I am going to assume they should be populated? I know nothing about NGINX, sorry about the noob questions.

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 404;
}

server {
    listen 80;
    listen [::]:80;
    server_name techexam.hopto.org;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name techexam.hopto.org;

    ssl_certificate /etc/letsencrypt/live/techexam.hopto.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/techexam.hopto.org/privkey.pem;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    include /etc/nginx/mime.types;
    charset UTF-8;

    location /static/ {
        alias /home/sfarmer/code/django_workspace/exam/Quiz/static/Quiz/;
    }

    location /media/ {
        alias /home/sfarmer/code/django_workspace/exam/Quiz/static/Quiz/;
    }

    location / {
        proxy_pass http://127.0.0.1:8000/;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        # Additional logging
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        error_page 502 /error_pages/502.html;
        location = /error_pages/502.html {
            internal;
            root /usr/share/nginx/html;
        }
    }
}
Steve
  • 1,028
  • 7
  • 25
  • 42

0 Answers0