0

I have a fullstack node express which serve static files and the api running on port 5000.

my nginx config is :

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name mycoolserver.com;

        location / {
          try_files $uri $uri/ =404;
        }
}

server {
       listen 80;
       listen [::]:80;
       
       server_name fancyapp.mycoolserver.com;

       location / {
         proxy_pass http://127.0.0.1:5000/;
       }
}

I can load the index.html at http://fancyapp.mycoolserver.com but the css and js from this file failed to be loaded.

If I try to access some of the api, eg: http://fancyapp.mycoolserver.com/birds, it's working.

I've read countless stackoverflow posts and google it for days without success.

1 Answers1

0

Most likely your site URL is not set correctly in your application.

I don't see any point to serve static assets via your backend application. You don't get practically any benefit from having nginx in the front...

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63