I’m trying to come up with a nginx configuration file for a
fallback-like directory structure.
I have the following directories:
/var/www/base/ (generic files)
/var/www/site1/ (files specific to site1)
Given a request for /logo.png, I would like nginx to do the following:
serve /var/www/site1/logo.png if exists; otherwise
serve /var/www/base/logo.png.
The matter is complicated by the presence of PHP files. Given a request
for /index.php (possibly in the same directory as image files…) nginx
should:
serve /var/www/site1/index.php through FastCGI, if the php file
exists; otherwise
serve /var/www/base/index.php through FastCGI.
Can anybody please suggest the optimal combination of document_root,
alias, location, rewrite, try_files or such options to use? I would like
to avoid client-side redirects. Everything else is ok.
The final parameter for try_files SHOULD be a guaranteed to exist
location (such as your static 404 page).
if does indeed add a bit of overhead into things but there’s no real
numbers to suggest how much – for most purposes it’s obviously not
TOO much, but there’s no point in wasting resources just to waste
them, either.
You’re welcome. Please note a small typo, I did not end the
error_page declaration with a semicolon. There might be other small
errors I apologize for :). If you review the documentation at http://wiki.nginx.org regarding these directives it should all be very
clear to you :).
Good luck!
– Merlin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.