I have a Angular build and an Django backend providing API's running on one server. I've configured them in nginx with the frontend having a proxy to the backend server.
The backend is running on the url 127.0.0.1:8000/api and the frontend is running on localhost
Config:
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
charset utf-8;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;
gzip on;
gzip_types text/css text/javascript application/x-javascript application/json;
location /api {
proxy_pass http://127.0.0.1:8000/api;
}
location / {
try_files $uri $uri/ /index.html;
}
}
}
Now when I do any api call from the frontend I get the a 502 Bad Gateway error
GET http://localhost/api/posts/post/management 502 (Bad Gateway)