SSL configuration with Nginx with Django

I am trying to configure the SSL to the environment. The combination of technical stack nginx, Angular and Django. I downloaded the cert and placed into the server for the nginx and added the below configuration in the Django - settings.py for the SSL in the backend.

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

Added the below configuration in the nginx server block.

server {
 
    listen 8000 ssl;
   
    ssl_certificate /etc/ssl/servername.crt;
    ssl_certificate_key /etc/ssl/servername.key;
    ssl_password_file /etc/ssl/global.pass;
    server_name  localhost;
 
    underscores_in_headers on;
    client_max_body_size 2500M;
 
 
    location / {
 
        proxy_set_header X-Real-IP $remote_addr;
 
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
 
        proxy_set_header Connection "Upgrade";
 
        proxy_connect_timeout 3600s;
 
        proxy_read_timeout 3600s;
 
        proxy_send_timeout 3600s;
 
        proxy_pass https://backend;
 
          
    proxy_ssl_protocols           TLSv1 TLSv1.1 TLSv1.2;
        
    
    proxy_ssl_password_file /etc/ssl/global.pass;
        
    }
 
}

Tried the few stackoverflow solutions, but nothing works.

I am getting the below error messge

Access to XMLHttpRequest at '
https://servername/login/'
from origin '
https://servername:4200'
has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Just want to get more clarity on the nginx configuration. Did I miss anything? I searched few answers but unable to get the solution.

Back to Top