Nginx não consegue redirecionar arquivos js, css, jpeg

Nginx não consegue redirecionar arquivos js, css, jpeg

Encontre o arquivo nginx.conf conforme abaixo:

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;

   }
...

Quando estou abrindo www.mysite.com/temp/something do chrome, ele está pegando o index.html corretamente, mas descansando todos os js, css, jpeg, png etc., ele está pegando de /home/ubuntu/mysite/dist em vez de /var/www /frontend-stage/dist/alguma coisa/

Estou usando Angular 9 no front-end

por favor, avise

Responder1

Você tem um conjunto raiz de documentos, então ele está usando esse caminho root /home/ubuntu/mysite/dist;

Veja aqui: https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/

informação relacionada