i have /var/www/html/
with index.html
i have /var/www/ai_backend
with server.js
server.js is running on port 5000. so if i curl from this machine http://localhost:5000 i get response.
but if i send post request from index.html to server_ip/api i'm getting error
POST http://server_ip/api 404 (Not Found)
this is my nginx conf file
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name <server_ip>; # i have real ip in config file
location / {
# serve static frontend first
try_files $uri $uri/ /index.html;
}
# location ~*^/(api|posts|products) {
location /api {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}