Nginx Alternative Root With Conditional Autoindexing
#nginxRecently I have developed the following Nginx setup to make my virtual host instance more advanced. It has the following features:
- The blog root directory served from a completely different directory than the regular
htdocs
root. Blog content has preference over the other files, so if the requested file is not found in the blog root, it falls back to the regular root. - There is a feature for conditional autoindexing (I don’t like to expse my files by default): if I put a
.index
file into a directory, it will be publicly autoindexed, otherwise Nginx returns a 404 error (as instead on the default 403). - Handles
error_page
idoms well.