1👍
It won’t work that way.
First, you have to understand how HTTP requests work. Each request, either for your website or for static files is separate and it have it’s own URL. Nginx can’t pair by itself request for static file to request for website from which that static file was requested…
The only way that nginx may know that is Referer
header, that browser can send with request to static file. This may contain path to web document from which static file was requested, but it also can be empty! It also can just contain path to root of your website.
Also, browsers will try to cache everything they can, so if user visits http://example.com/testapp1
and that site contains reference for http://example.com/static/style.css
, browser will cache it and on request to http://example.com/testapp2
browser won’t download new css file, but will rather use cached one.
If you’re sure that your web clients will always send proper Referer
header and won’t cache any static files, you may try to extract path to app from $http_referer
variable in nginx.
0👍
Set the static location inside each server block
server {
listen 80;
server_name pool.simlabdevelopments.com;
root /srv/http/simlabdevelopments.com;
location /static/ {
alias /srv/webapps/autopool/static/;
}
}