关于在windows系统下nginx部署静态资源文件时遇到的路径问题

server {
listen 80;
server_name localhost;
access_logC:/web/access.log;
error_logC:/web/error.log;
location / {
proxy_pass http://localhost:8081;
}
location /static/ {
root C:/static/;
autoindex on;
}
}

这是我的nginx.conf中的一部分信息,我设置了/static/作为我的静态资源库,指定的路径是C:/static ;
这时候正常来说应该是:
路径:C:/static/1.txt 的文件,我通过 http://localhost/static/1.txt 就可以访问到了,但是事实是我怎样都访问不到,系统会报错,提示我访问的是 C:/static/static/1.txt 文件,一脸懵逼。于是我把nginx.conf里的root路径上调,改成了C:/ ,才能正常使用
server {
listen 80;
server_name localhost;
access_logC:/web/access.log;
error_logC:/web/error.log;
location / {
proxy_pass http://localhost:8081;
}
location /static/ {
root C:/;
autoindex on;
}
【关于在windows系统下nginx部署静态资源文件时遇到的路径问题】}
这样修改后重启nginx,我通过 http://localhost/static/1.txt 就可以访问到了路径为 C:/static/1.txt 的文件。
甚是奇怪,希望有大神给我解惑,为什么多了一层目录。

    推荐阅读