Im learning nginx and referring to book "nginx essential-valery kholodkov" for settingup nginx 1.8 and Im using centos 7 (selinux is off).

i made some changes to documentroot(like in apache 2.x) default configuration and when i add a location /images like below

server {
listen       80;
server_name  localhost;
#charset koi8-r;
#access_log  /var/log/nginx/log/host.access.log  main;

location / {
root /var/www/html/example.com;
index  index.html index.htm;
location /images {
root /disk2/images;

On browser when i browse to example.com/images/pen.jpg i get 404 not found error. but when i use alias it will work and pen.jpg is displayed. below is configuration (location part) that worked

location /images {
alias /disk2/images;

1 Answer 1


I found my solution here multiple roots on nginx answered by Shafiul karim

The Location directive system is like you want to forward all request which start /static and your data present in /var/www/static so the configuration below worked!

location /images {
root /disk2;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .