0

I am trying to configure a reverse proxy for nginx to serve an angular site but am struggling with the upstream server.

All of the info I have found researching indicates that nodejs should be running locally on the ubuntu vps (usually at localhost:3000) and have the nginx reverse proxy to it or to use docker.

I have uploaded the /dist contents after ng build but am unsure how to get node to serve this. The tutorials all seem to do ng serve on a newly generated angular project, not a prebuilt one.

I'm guessing its a noob mistake, as its my first angular project.

I have a django backend already working and serving through nginx on a subdomain, but cannot seem to get the angular front end working in the same configuration file.

The current nginx site configuration I have is:

server {
    listen 80;
    server_name <non-www domain> <www domain>;
    root /home/www/f_end/;
    
    location / {
        autoindex off;
        index index.html;
        proxy_pass http://0.0.0.0:3000;
        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;
    }
}

which passes an sudo nginx -t but returns a 404 error.

I'm not sure what other info would help to diagnose the problem, but ideally would have the backend point to the api subdomain and the angular app pointed to the www and non-www domains.

Stiofán
  • 1
  • 3

0 Answers0