Nginx Setup für React Plus Django (REST Framework) auf demselben Server

server_tokens               off;
access_log                  /var/log/nginx/mysite.access.log;
error_log                   /var/log/nginx/mysite.error.log;

# This configuration will be changed to redirect to HTTPS later
server {
  server_name               .example.com;
  listen                    80;
  location / {
        root   /var/www/html;  # location for React build files
        index  index.html index.htm;	# entry point for NGINX
		try_files $uri $uri/ /index.html;
  }

  location /akn {
        try_files $uri @proxy_api;	# call to pass proxy
  }
  location /admin {
    	try_files $uri @proxy_api;  # to use the default django admin
  }

  location @proxy_api {
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Url-Scheme $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass   http://localhost:8000;
   }

  location /staticfiles {
	autoindex on;
	alias /var/www/akn/static/;
  }
}
Yucky Yak