Reputation: 4968
This is how my configuration looks like...
server {
listen 80;
server_name 127.0.0.1 localhost;
location = / {
index index.html;
}
location / {
root /etc/nginx/html/app1;
}
}
In my folder app1 I have two files, index.html & home.html
If I browse http://localhost/ or http://localhost/index.html or http://localhost/home.html page it comes up well.
When I change the configuration like so...
server {
listen 80;
server_name 127.0.0.1 localhost;
location = / {
index home.html;
}
location / {
root /etc/nginx/html/app1;
}
}
http://localhost:8888/index.html > works http://localhost:8888/home.html > works http://localhost:8888/ > 403 forbidden!!!
Can someone please tell me what is wrong?
Upvotes: 1
Views: 109
Reputation: 1234
Because the priority of location = {}
is higher location / {}
.
So it first matches the location = {}
.
In you case, there isn't root in the location = {}
.
Upvotes: 1