Nginx Serve 2 Different Directories With 2 Different URLs -


what trying use nginx serve 2 different directories in different places on file system using 2 different urls. so, given 2 directories on filesystem /path/to/dir1 , /path/to/dir2 want users on website able access mysite/d1 , mysite/d2 , have each of urls serving dir1 , dir 2 respectively. here have tried:

server {          listen       80;          location /d1/ {             root    /path/to/dir1;             autoindex on;         }          location /d2/ {             root   /path/to/dir2;             autoindex on;         }      } 

i bit confused why isn't working, because when use config

server {      listen       80;      location / {         root    /path/to/dir1;         autoindex on;     }  } 

and navigate mysite/ can access dir1 expected

the problem appending of request uri when use root

  location /d1/ {         root    /path/to/dir1; 

this means want search files in /path/to/dir1/d1/. need alias because in case of alias request_uri taken after declared location

server {          listen       80;          location /d1/ {             alias    /path/to/dir1;             autoindex on;         }          location /d2/ {             alias   /path/to/dir2;             autoindex on;         }      } 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -