I would like to serve an index file from a root folder and one from a subfolder from root.
My nginx server conf looks as follows:
server {
listen 80;
server_name localhost;
root /data/;
index index.html index.htm index.txt;
location / {
}
location /a {
alias /data/a/;
}
}
and my directory structure looks as follows:
/data/:
a index.txt
/data/a:
index.txt
If I then do curl localhost
, I get the contents of the file /data/index.txt
.
But curl /localhost/a
gives me a 301
.
curl localhost/a/index.txt
works.
Why can't I access my index.txt with curl /localhost/a
?
I tried using a root
instead of alias
in the location /a
block and also tried to specify the index.txt
for location /a
, but no success.
I see similar posts, e.g. Nginx location configuration (subfolders) but couldn't yet find the answer.