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 的文件。
甚是奇怪,希望有大神给我解惑,为什么多了一层目录。
推荐阅读
- Go|Docker后端部署详解(Go+Nginx)
- 后台|NATAPP内网穿透通过nginx实现一个端口访问多个不同端口服务
- nginx-1.20.2安装使用
- NGINX 创始人 Igor Sysoev 退出 F5(20 年发展“简史”令人肃然起敬)
- Nginx|Nginx~从入门到入坑。
- nginx|Mac配置PHP环境(brew安装nginx+php)
- 使用ngx_lua构建高并发应用(2)
- svn|前瞻(Spring Boot 2.4.0 第二个里程碑版本发布)
- nginx cache踩坑
- keepalived + nginx组建高可用负载平衡Web server集群