1.举例说明:
location /im/ { root /s/html/; try_files $uri $uri/ /im/default.gif; } 比如 请求 127.0.0.1/im/test.gif 会依次查找 1.文件/s/html/im/test.gif 2.文件夹 /s/html/im/test.gif/下的index文件 3. 请求127.0.0.1/im/default.gif 4.其他注意事项 1.try-files 如果不写上 $uri/,当直接访问一个目录路径时,并不会去匹配目录下的索引页 即 访问127.0.0.1/im/ 不会去访问 127.0.0.1/im/index.html
2 如果用 http://172.168.10.10/proxy/index.html 访问
1:location /proxy/ {
proxy_pass http://127.0.0.1/;
}
表示代理到URL:http://127.0.0.1/index.html
2:location /proxy/ {
proxy_pass http://127.0.0.1/aaa/;
}
表示代理到URL:http://127.0.0.1/aaa/test.html
就是把匹配到/proxy的路径代理到 proxy_pass http://127.0.0.1/;
【1】Nginx——location常见配置指令,alias、root、proxy_pass_Leeon的博客-CSDN博客