I am working on replacing an apache old home directory web server - users can host static files/web pages in their home directories. I'm sure that my approach is not prefect but it works except for any path that has a space in it. The home directories are split across a few different folders like so:
basedir
└───faculty
│ └───user1
│ └───public_html
│ └───user2
│ └───public_html
│ │...
└───staff
│ └───user1
│ └───public_html
│ └───user2
│ └───public_html
│ │...
└───students
│ └───user1
│ └───public_html
│ └───user2
│ └───public_html
│ │...
My almost working solutions looks something like this:
location ~ "^/~(.+?)(/.*)?$" {
set $userAlias "notfound";
if (-d /basedir/faculty/$1/public_html/){
set $userAlias "/basedir/faculty/$1/public_html$2";
}
if (-d /basedir/staff/$1/public_html/){
set $userAlias "/basedir/staff/$1/public_html$2";
}
if (-d /basedir/students/$1/public_html/){
set $userAlias "/basedir/students/$1/public_html$2";
}
alias '$userAlias';
index index.html index.htm;
autoindex on;
}
The issue is that $userAlias does not get the normalized string, so any path with space tries to resolve a path with "%20" in it, which will not exist.
I am open to any advise.