I am using Nginx to host my React application that makes calls to a Django application. Getting "Too many redirects" error when I visit the site
My React application is set up internally to make calls to my application built using Django Rest Framework. I am using both Gunicorn and Nginx, here is my Nginx config file.
server {
listen 80;
server_name domain.com www.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name domain.com www.domain.com;
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
# Root directory of React build
root /home/ubuntu/Project-Frontend/build;
index index.html index.htm;
location / {
try_files $uri /index.html =404;
}
# Proxy requests to Django backend
location /userapi/ {
proxy_pass https://unix:/run/gunicorn.sock;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
The Nginx server worked until I attempted to add SSL using Certbot, after which I am just completely unable to access the site. I have tried checking both applications for issues and have found nothing. I have also been looking through similar posts to try and find a solution and so far nothing has worked, I would be extremely grateful for any help.
source https://stackoverflow.com/questions/77294271/i-am-using-nginx-to-host-my-react-application-that-makes-calls-to-a-django-appli
Comments
Post a Comment