I want to add different configuration file(s) to different directories. For example:
root /var/www/root/html
location / {
root /var/www/root/html
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
include a.conf
include phphandler.conf
}
location /dir1/ {
root /var/www/dir1/html
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
include b.conf
}
location /dir2/ {
root /var/www/dir2/html
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
include c.conf
include phphandler.conf
}
So each directory has own .conf file (e.g. a.conf, b.conf) which contains their own php handling options, error handling options etc. and there is common conf file (phphandler.conf) which contains configuration that applies on all subdirectories.
Will this work? I want to seperate error pages and configuaration files for each subdirectories.
Also, will updating nginx restore /site-available/default to theit default configuation?
Answer to your question is yes it will be work, but don't do it in location /
in your main nginx.conf
you have to write paths to include
for example now you have only one include /etc/nginx/sites-enabled/*;
just add another one include /etc/nginx/yourdir/*;