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

1 Answer 1

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...

2
  • This configuration looks incomplete, there is no value set to $1 variable. Oct 1, 2021 at 6: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 1, 2021 at 8:23

You must log in to answer this question.

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