0

Please find by nginx.conf file as below :

server {
    listen   81;

    server_name www.mysite.com;
    root /home/ubuntu/mysite/dist;
    index index.php index.html index.htm;

    charset utf-8;

        # Remove trailing slash to please Laravel routing system.
        #if (!-d $request_filename) {
        #rewrite  ^/(.+)/$ /$1 permanent;
        #}

    error_log  /var/log/nginx/myapp-error.log warn;
location / {
    try_files $uri /index.html;
   }
 location /temp {
        alias /var/www/frontend-stage/dist/something/;
        # basically $uri and /$uri resembles the base path which is / and the path on which we're currently, so for an example if i
        # want to host another website on /temp/foo the the $uri /temp/$uri
         try_files $uri $uri/ /temp/index.html;

   }
...

When I am opening www.mysite.com/temp/something from chrome its taking the index.html correctly bur rest all js, css , jpeg, png etc it is taking from /home/ubuntu/mysite/dist instead /var/www/frontend-stage/dist/something/

I am using Angular 9 in frontend

Please advise

1
  • You seem to be saying that your js, css and jpeg files are in a different location/different route from the HTML content / content generation scripts. For nginx to be able to serve these up as if they were in the same path, you have to tell nginx how to do that. You do not appear to have tried.
    – symcbean
    Oct 5, 2022 at 20:38

1 Answer 1

0

You have a document root set, so it is using that path root /home/ubuntu/mysite/dist;

See here: https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .