Score:0

NGINX serve different paths from different locations

ke flag

I have poked around in all similar topics and can't seem to cut through this one.

My set up: 2 different JS apps served through their index.html files:

/var/www/html/original_dir/dist -> served from my.awesomesite.com

/var/www/html/not_so_original_dir/dist -> served from my.awesomesite.com/oldie

server {
  root /var/www/html/original_dir/dist;
  index index.html;
  server_name my.awesomesite.com;
  location ~* \.(?:css|js)$ {
    expires 1y;
    access_log off;
  }
}

I guess using an alias could solve this.

server {
  root /var/www/html/original_dir/dist;
  index index.html;
  server_name my.awesomesite.com;
  location /oldie {
    alias /var/www/html/not_so_original_dir/dist;
    index index.html;
  }
}

When my.awesomesite.com/oldie is accessed the correct index.html is requested however all css and js references are resolved with old location: Fx a reference for /css/app.css at my.awesomesite.com/oldie is attempting to be resolved at /var/www/html/original_dir/dist/css/app.css instead of /var/www/html/not_so_original_dir/dist/css/app.css.

Any idea on how to fix the files so to be delivered through the correct folder?

Gerard H. Pille avatar
in flag
Did you try a "./css/app.css" reference?
us flag
Please add the complete nginx configuration as given by `nginx -T` command to the question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.