0

I'm currently trying to fiddle around with a location block that has a different root. However I have some issues when accessing files that are in a subfolder on the different root.

Here is my broken location block and below it I will explain the exact issue:

  location /maps                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
    {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
        alias /online/www/maps.domain.com;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
        try_files $uri $uri/ @nested;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
   location @nested {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
        rewrite /maps/(.*)$ ~/maps/$2;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    }                                      

Here I try that /maps on my root domain (domain.com/maps) has a different root. That works for files directly on /online/www/maps.domain.com

However if I have a subfolder there e.g. /online/www/maps.domain.com/folder1 I can't speak to it via domain.com/maps/folder1 and so can't access files there.

Is there any "dynamic" way to achieve this? Or do I need to add another location block for that sub-sub-folder?

Thanks.

~ Alex

Aebian
  • 23
  • 6

1 Answers1

0

After posting the question and getting some coffee I found the solution... And it was really that simple too,.

Here it is:

location /maps                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
    {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
        alias /online/www/maps.domain.com/$1;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    }                    

Only thing I had to do was adding a variable at the end of the folder alias. Yikes...

Aebian
  • 23
  • 6
  • This configuration looks incomplete, there is no value set to `$1` variable. – Tero Kilkanen Oct 01 '21 at 06:32
  • However it works for me nonetheless. My assumption is that $1 will be filled with a default value from the url when not explicitly specified. – Aebian Oct 01 '21 at 08:23