How to configure nginx for backend in django and frontend on nuxt.js?

Greetings to all! Things such nuxt raised using pm2 on port 5006 using the server-side rendering. Is django on the same server, on port 5007 with gunicorn, which serves only to query the api and access the admin panel.
My task is to using nginx to proxy all requests on the frontend, except for requests to /api/, /admin/, and apparently /static/. Single domain certificate from letsencrypt.

I tried to do so, stupid writing different location:
server {
 server_name test.com www.test.com;
 gzip on;
 gzip_types text/plain application/xml text/css application/javascript;
 gzip_min_length 1000;
 include /etc/nginx/snippets/letsencrypt.conf;

 location / {
 include proxy_params;
 proxy_pass http://localhost:5006;
}

 location /api/ {
 include proxy_params;
 proxy_pass http://unix:/home/path/to/core.sock;
}
 location /admin/ {
 include proxy_params;
 proxy_pass http://unix:/home/path/to/core.sock;
}
 location /static/ {
 root /home/path/to/staticfolder;
}
 return 301 https://$host$request_uri;
}

server {
 listen 443 ssl http2;
 listen [::]:443 ssl ipv6only http2=on;
 server_name test.com;
 include /etc/nginx/snippets/letsencrypt.conf;
 location / {
 include proxy_params;
 proxy_pass http://localhost:5006;
}
 location /api/ {
 include proxy_params;
 proxy_pass http://unix:/home/path/to/core.sock;
}
 location /admin/ {
 include proxy_params;
 proxy_pass http://unix:/home/path/to/core.sock;
}
 location /static/ {
 root /home/path/to/staticfolder;
}
 ssl_certificate /etc/path/to/fullchain.pem;
 ssl_certificate_key /etc/path/to/privkey.pem;
 ssl_trusted_certificate /etc/letsencrypt/live/test/fullchain.pem;
 include /etc/nginx/snippets/ssl.conf;
}


This configuration gives nuxt, but on request to api / I get 502 Bad gateway from nginx. This bundle want to use always and everywhere, so I would like to understand how using it with nginx configure. Help, comrades, please)
June 5th 19 at 21:02

Find more questions by tags DjangoNginxServer-Side RenderingVue.js