My application uses a single web app (in HTML and Javascript) to serve multiple (dynamic amount) system.
Systems are distinguished by URL like http://localhost/sites/<system-id>, where system-id allows only lowercase letter.
Suppose that the web app is located in /opt/myapp. How to config that in nginx?
I tried following methods but none works.
location ~ /sites/[a-z]+ {
alias /opt/myapp;
index index.html index.htm;
}
Enter http://localhost/sites/abc/, got 403 forbidden.
Enter http://localhost/sites/abc/index.html, still 403 forbidden and URL auto changed to http://localhost/sites/abc/index.html/
Same result for location ~ /sites/[a-z]+/ {}
I tried
location ~ /sites/[a-z]+ {
alias /opt/myapp/;
index index.html index.htm;
}
Enter http://localhost/sites/abc, URL redirected to http://localhost/sites/abc/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/