About nginx path encountered when deploying static resource files in the windows system problems

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

}

 

This is part of the information in my nginx.conf, I set / static / I as a static repository specified path is C: / static; 

Normally at this time it should be:

Path: C: /static/1.txt file, I passed http: can access //localhost/static/1.txt to, but the truth is what I do not visit, the system error, prompted me to visit is C: /static/static/1.txt file, and a look ignorant force. So I nginx.conf increase in the root path, into the C: /, you can use normal

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

}

This amendment restart nginx, I passed http: //localhost/static/1.txt can access to the path is C: /static/1.txt file.

Very strange, I hope to God I have big doubts, why more than one directory.

Published 20 original articles · won praise 8 · views 50000 +

Guess you like

Origin blog.csdn.net/a26637896/article/details/88892535