Proxying and static files
Francis Daly
francis at daoine.org
Thu Feb 16 21:38:21 UTC 2017
On Thu, Feb 16, 2017 at 08:26:35AM -0500, epoch1 wrote:
Hi there,
> I've tried something like the following but can't get it work for each app:
> location ~* /(images|css|js|files)/ {
> root /home/username/app1/public/;
> }
>
> If I request app1/js/script.js for example it goes to
> /home/username/app1/public/app1/js/script.js rather than
> /home/username/app1/public/js/script.js
If the web request /one/two/thr.ee does not correspond to a file
/docroot/one/two/thr.ee, then you probably want to use "alias"
(http://nginx.org/r/alias) instead of "root".
It's not clear to me what your exact pattern for recognising "static"
vs "dynamic" files is; perhaps something like one of
location /app1/images/ {
alias /home/username/app1/public/images/;
}
(with similar things for the other directories); or
location ~* ^/app1/(images|css|js|files)/(.*) {
alias /home/username/app1/public/$1/$2;
}
or
location ~* ^/app1/(.*.(js|css))$ {
alias /home/username/app1/public/$1;
}
In each case, the "location"s (particularly the regex one) could be
nested within the matching "main" location that you already have.
God luck with it,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list