Nginx: Why the index directive can't work, 403 forbidden?

Viewed 549

The nginx.conf is as following:

user  www-data;
worker_processes  1;

error_log  logs/error.log;
error_log  logs/error.log  notice;
error_log  logs/error.log  info;

events {
    worker_connections  1024;
}
http {
    server {
        listen 8080;
        server_name example.com;
        root /tmp/test/example;

        location = / {
            index index.html;
        }

        location / {
            root /tmp/test/mydomain;
        }
    }
}

The errors.log is:
2016/03/22 23:07:56 [error] 17763#0: *1 directory index of "/tmp/test/example/" is forbidden, client: 127.0.0.1, server: example.com, request: "GET / HTTP/1.1", host: "example.com:8080"

But when I comment the line root /tmp/test/example, it works fine. So I want to know how the index redirect works?

1 Answers
Related