Serving React and Django with SSL and a domain

Viewed 717

Currently, I'm deploying a react app and using django as the backend API on an ubuntu nginx server. The react app is already online have a SSL certificate, but the backend API does not. By default, browsers can't show a http content on a https connection.

Do I need to get another SSL certificate afor the backend API? Or is there another way to do it?

Nginx conf file (for the frontend part. I'm not sure how to configure the backend):

The backend is currently running on xxx.xx.x.xx:8000 (using gunicorn --daemon --bind xxx.xx.x.xx:8000)

server {
   server_name xxxxxx.com www.xxxxxx.com xxx.xx.x.xx;
   root /var/www/frontend/build;
   index index.html index.htm;
   location / {
   try_files $uri $uri/ /index.html =404;
   }


    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/fromnil.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/fromnil.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;


}
server {
    if ($host = www.xxxxxx.com) {
        return 301 https://$host$request_uri;
    }


    if ($host = xxxxxx.com) {
        return 301 https://$host$request_uri;
    }


   server_name xxxxxx.com www.xxxxxx.com xxx.xx.x.xx;
    listen 80;
    return 404;




}

Thanks

Found this link, but wasn't able to post a comment because my reputation is not enough. And I don't really understand. Can anyone help me?

How to deploy react and django in aws with a ssl and a domain

0 Answers
Related