Does nginx specify a path to access static pages?

I want my http://119.28.133.206/git to open index.html

in my corresponding folder.

I am now through this

server {
    listen       80;        -sharp
    server_name  localhost;   -sharp
    index  index.html;
    charset utf-8; -sharp 
    root /data/learnGitBranching;
}

implements the interface that http://119.28.133.206/ has the presentation I need.
but I want to configure

this way.
server {
    listen       80;        -sharp
    server_name  localhost;   -sharp
    charset utf-8; -sharp 

    
      location /git {
        index  index.html;
        root /data/learnGitBranching;
        autoindex on;             -sharp
    }
}

visit http://119.28.133.206/git to display 404 and then find

2018/08/20 17:02:56 [error] 7026-sharp7026: *1 open() "/data/learnGitBranching/git" failed (2: No such file or directory), client: 122.224.133.218, server: localhost, request: "GET /git HTTP/1.1", host: "119.28.133.206"

so I changed the visit to http://119.28.133.206/index.html
, which shows the welcome interface of nginx . I saw log

.
-sharpaccess.log
122.224.133.218 - - [20/Aug/2018:17:03:27 +0800] "GET /index.html HTTP/1.1" 200 396 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"

and then I change it like this

    location /git {
      -sharp  index  index.html;
        alias /data/learnGitBranching/index.html;
        autoindex on;             -sharp
    }

that"s great. Visit url/git and download my html directly.

I also try to change alias to path but can"t start nginx what"s the right way?

I would like to ask if there is an introduction to nginx , which allows me to understand the url corresponding to the configurations completed by various combinations of location, path, root, alias .

Apr.17,2021

correct configuration:

    location /git/ {
        index  index.html;
        alias  /data/learnGitBranching/;
        autoindex on;
    }

just look directly at the official documents:
https://nginx.org/r/location
https://nginx.org/r/root
https://nginx.org/r/alias

Menu